Repository navigation
Where
Dennis Corvers edited this page Oct 23, 2026
·
2 revisions
Filters an Enumerable to include only values accepted by a predicate. where
is deferred: the predicate runs when the returned Enumerable is iterated.
filtered = source:where(predicate)| Parameter | Type | Description |
|---|---|---|
predicate |
function(value, position) |
Returns true to keep the value. Position is 1-based. |
A new Enumerable containing values for which the predicate returns true.
The predicate must return the boolean true to retain a value. It receives the
value and its 1-based position in the source sequence.
local availableFood = LuaQ.from({
{ item = "Shark", quantity = 12 },
{ item = "Saradomin brew", quantity = 0 },
{ item = "Manta ray", quantity = 6 },
})
:where(function(stack) return stack.quantity > 0 end)
:toTable()
-- Keeps the Shark and Manta ray stacks- 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