Repository navigation
First
Dennis Corvers edited this page Oct 23, 2026
·
1 revision
Returns the first value in an iterable, optionally requiring a predicate match.
value = values:first(predicate)| Parameter | Type | Description |
|---|---|---|
predicate |
function(value, sourceKey) (optional) |
Returns true for the desired value. |
The first value, or the first value whose predicate returns exactly true.
Raises an error if the iterable is empty or no value matches. With a predicate, the callback receives the source iterator key.
local firstVeteran = LuaQ.from({
{ name = "Ada", level = 42 },
{ name = "Bryn", level = 81 },
{ name = "Cato", level = 93 },
})
:first(function(player) return player.level >= 80 end)
-- firstVeteran.name is "Bryn"FirstOrDefault · Last · Single · Functions
- 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