Repository navigation
ToMap
Dennis Corvers edited this page Oct 23, 2026
·
1 revision
Converts values into a Lua table whose keys and values may be selected from each source entry.
map = values:toMap(keySelector, elementSelector)| Parameter | Type | Description |
|---|---|---|
keySelector |
function(value, sourceKey) (optional) |
Returns the output key. Without it, the source key is used. |
elementSelector |
function(value, outputKey) (optional) |
Returns the output value. Without it, the original value is used. |
A Lua table mapping each output key to its value.
If multiple entries produce the same key, the later value overwrites the
earlier value. toDictionary is an alias.
local playersById = LuaQ.from({
{ id = 41, name = "Ada" },
{ id = 58, name = "Bryn" },
})
:toMap(
function(player) return player.id end,
function(player) return player.name end
)
-- playersById[58] is "Bryn"- 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