first multimethod
Methods
- first(e:Eachable1, predicate:Any, default:Any) Source: stdlib.ngs:346
Find first element in e that satisfies the predicate. Returns
Either the element or the provided default if element was not found.Example
(10..20).first(F(x) x % 3 == 0) # 12 - first item divisible by 3 (10..20).first(F(x) x % 50 == 0, 1000) # 1000
- first(e:Eachable1, predicate:Any) Source: stdlib.ngs:362
Find first element in e that satisfies the predicate. Throws ElementNotFound exception if no such element is found. Returns
The element.Example
(10..20).first(F(x) x % 3 == 0) # 12 - first item divisible by 3 (10..20).first(F(x) x % 50 == 0) # ElementNotFound exception
- first(e:Eachable1) Source: stdlib.ngs:377
Find first element in e that satisfies Bool(e) == true. Exactly same as first(e, identity). Example
[false, 0, null, "xyz", 100].first() # "xyz" [].first() # ElementNotFound exception