Enumerable First - FireDragon91245/Lua-Linq GitHub Wiki

enumerable:first

Returns the first item in the sequence, or the first projected value when you pass a selector.

Overloads

enumerable<T>   :first():                                       T
enumerable<K, V>:first():                                       K, V

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

enumerable<T>   :first(selector: string):                       any
enumerable<K, V>:first(selector: string):                       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 first = linq.list(4, 12, 7):first()
local name = linq.list({ name = "iron" }, { name = "copper" }):first("name")
⚠️ **GitHub.com Fallback** ⚠️