Repository navigation
ElementAtOrDefault
Dennis Corvers edited this page Oct 23, 2026
·
1 revision
Returns the value at a specified 1-based position, or a default when that position is not present.
value = values:elementAtOrDefault(index, defaultValue)| Parameter | Type | Description |
|---|---|---|
index |
positive integer | 1-based position of the requested value. |
defaultValue |
any (optional) | Value returned when the position is outside the iterable. |
The value at index, or defaultValue if there is no value there.
The index must still be a positive integer, even when a default is provided.
The default is nil if omitted.
local standby = LuaQ.from({
{ name = "Ada" },
{ name = "Bryn" },
})
:elementAtOrDefault(3, { name = "Reserve" })
-- standby.name is "Reserve"- Home
- Getting Started
-
Functions
- aggregate
- all
- any
- concat
- contains
- count
- create
- createFrom
- deepCopy
- difference
- elementAt
- elementAtOrDefault
- first
- firstOrDefault
- flatMap
- foreach
- groupBy
- groupByResult
- indexOf
- intersect
- ipairs
- last
- lastOrDefault
- map
- max
- min
- pairs
- sequenceEquals
- single
- singleOrDefault
- sort
- sortBy
- sortByDescending
- sortDescending
- sum
- take
- takeWhile
- thenBy
- thenByDecending
- toLookup
- toMap
- toSet
- toTable
- union
- unique
- where
- zip
- Aliases