Returns the number of items in a collection.
When the argument is a table, string or array, it returns the number of elements or entries stored by that collection.
The argument may also be an iterator. In that case, the result is:
- An integer, if the iterator knows its exact length
- The symbol
infinite, if the iterator knows itself to be infinite - The symbol
unknown, if the iterator does not know its exact length
Iterators are quite conservative when reporting their length. For example, array iterators
report their length as unknown, because it's possible that additional elements may be
pushed to the array during iteration.