first
first <iterable>
The first element of an iterable.
Arguments
Returns
The first element, or null if the iterable is empty.
Examples
after command (say) {
do "say The first word is [first [words "alpha beta gamma"]]."
}
[first ...] evaluates to "alpha", so the mob says "The first word is
alpha."
after command (say) {
let target [first [creatures $self]]
unless [isnull $target]
do "smile $target"
}
target is bound to the first living creature in the owner's room. The
unless guard skips the smile when the room is empty
and first returned null instead of a creature.
See also
nth— any element by 0-based index.empty— test for no elements without pulling one out.choose— a random element instead of the first.- Iterables and iterables · Types