Repository navigation
TakeWhile
Dennis Corvers edited this page Oct 23, 2026
·
2 revisions
Returns values from the beginning of an Enumerable while a predicate accepts
each value. Enumeration stops at the first value the predicate rejects.
prefix = source:takeWhile(predicate)| Parameter | Type | Description |
|---|---|---|
predicate |
function(value, position) |
Returns true to keep the value and continue. Position is 1-based. |
A deferred Enumerable containing the initial consecutive values accepted by
the predicate.
The predicate must return exactly true to continue. Values after the first
rejected value are not examined.
local priceRange = LuaQ.from({
{ item = "Rune platebody", price = 38000 },
{ item = "Dragon boots", price = 42000 },
{ item = "Noxious scythe", price = 240000000 },
})
:takeWhile(function(offer) return offer.price < 50000 end)
:toTable()
-- Takes affordable offers up to the first expensive item- 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