Enumerable Select - FireDragon91245/Lua-Linq GitHub Wiki

enumerable:select

Projects each item into a new shape. For key/value enumerables you can return just a value or return a new key and value pair.

Overloads

enumerable<T>   :select(selector: fun(item: T): R):                 enumerable<R>
enumerable<K, V>:select(selector: fun(key: K, value: V): R):        enumerable<R>
enumerable<K, V>:select(selector: fun(key: K, value: V): (KO, VO)): enumerable<KO, VO>

enumerable<T>   :select(selector: string):                          enumerable<any> | enumerable<any, any>
enumerable<K, V>:select(selector: string):                          enumerable<any> | enumerable<any, any>
  • selector: string acts as a key/property selector when it does not contain =>. If it contains => it is treated as a lambda expression.

Examples

local doubled = linq.list(2, 4, 6):select("n => n * 2"):spread()
local renamed = linq.dict({ iron = 4 })
    :select(function(key, value)
        return key .. "-ore", value * 10
    end)
⚠️ **GitHub.com Fallback** ⚠️