Skip to content
Dennis Corvers edited this page Oct 23, 2026 · 2 revisions

Enumerable:map

Projects each value of an Enumerable into a new value. map is deferred: the selector runs as the returned Enumerable is iterated.

Syntax

projected = source:map(selector)

Parameters

Parameter Type Description
selector function(value, position) Produces the value to yield. Position is 1-based.

Returns

A new Enumerable containing the selector results. Selector results may be false, but must not be nil.

Remarks

select is an alias of map. The selector receives each source value and its 1-based position.

Example

local playerNames = LuaQ.from({
    { name = "Ada", role = "mage" },
    { name = "Bryn", role = "ranger" },
})
    :map(function(player) return player.name end)
    :toTable()
-- { "Ada", "Bryn" }

See also

Where · FlatMap · Functions

Clone this wiki locally