Returns the nth item in list . The first item in a list has an index of 1. If i is 0 or negative, the first item is returned as well. If i is larger than the length of list , the last item is returned.
nth ( i As Any; _
list As Any ) As Any
Argument | Type | Description |
---|---|---|
i | Any | The index of the item to return. |
list | Any | The list |
Intent >nth(3, {"a", "b", "c", "d", "e"})
--> "c"
Intent >nth(1, {"a", "b", "c", "d", "e"})
--> "a"
Intent >nth(0, {"a", "b", "c", "d", "e"})
--> "a"
Intent >nth(-1, {"a", "b", "c", "d", "e"})
--> "a"
Intent >nth(7, {"a", "b", "c", "d", "e"})
--> "e"
Intent >nth(2.7, {"a", "b", "c", "d", "e"})
--> "b"
While the index can be a number, it is rounded down.