Length of () | |
length of [ v] | |
Category | List |
Type | Reporter |
Introduced in | 1.3 |
The Length of () block is a List block and a Reporter block. The block reports how many items a list contains.
Example Uses
In certain projects, different events can happen based on the length of a value; this block can be used here.
Some common uses for the Length of () block:
- Checking the number of different items a player has obtained
say (join [You have ] (join (length of [list v]) [ different items.]))
- Iterating through a list by repeating the length amount of times.
repeat (length of [list v]) change [i v] by (1) say (item (i) of [list v]) for (2) seconds end
- Accessing the second last, for example, item of a list
(item ((length of [list v]) - (1)) of [list v])
See Also
- Length of () (Operators block) — the version for strings