Repository navigation
Single
Dennis Corvers edited this page Oct 23, 2026
·
1 revision
Returns the only value in an iterable, optionally restricted by a predicate.
value = values:single(predicate)| Parameter | Type | Description |
|---|---|---|
predicate |
function(value, sourceKey) (optional) |
Returns true for a matching value. |
The only value, or the only matching value.
Raises an error when there are no matches or more than one match.
local selectedTarget = LuaQ.from({
{ name = "General Graardor", marked = false },
{ name = "Sergeant Steelwill", marked = true },
{ name = "Sergeant Grimspike", marked = false },
})
:single(function(npc) return npc.marked end)
-- selectedTarget.name is "Sergeant Steelwill"- 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