Repository navigation
Last
Dennis Corvers edited this page Oct 23, 2026
·
1 revision
Returns the last value in an iterable, optionally requiring a predicate match.
value = values:last(predicate)| Parameter | Type | Description |
|---|---|---|
predicate |
function(value, sourceKey) (optional) |
Returns true for a matching value. |
The last value, or the last value whose predicate returns exactly true.
Raises an error if the iterable is empty or no value matches. For dictionary-
like tables, pairs order is unspecified, so “last” is not predictable.
local latestUpgrade = LuaQ.from({
{ item = "rune helm", tier = 1 },
{ item = "dragon helm", tier = 2 },
{ item = "masterwork helm", tier = 3 },
})
:last(function(gear) return gear.tier >= 2 end)
-- latestUpgrade.item is "masterwork helm"- 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