Repository navigation
Unique
Dennis Corvers edited this page Oct 23, 2026
·
2 revisions
Returns the first value for each distinct key in an Enumerable.
distinct = source:unique(keySelector)| Parameter | Type | Description |
|---|---|---|
keySelector |
function(value, sourceKey) (optional) |
Selects the key used to identify duplicate values. |
A deferred Enumerable with only the first value for each key, in source
iteration order.
If no selector is supplied, the value itself is used as the key. distinct is
an alias. Keys are stored in a Lua table and therefore must not be nil.
local players = {
{ name = "Ada", role = "mage" },
{ name = "Bryn", role = "ranger" },
{ name = "Cato", role = "mage" },
}
local firstByRole = LuaQ.from(players)
:unique(function(player) return player.role end)
:map(function(player) return player.name end)
:toTable()
-- { "Ada", "Bryn" }Difference · Union · Intersect · 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