index multimethod

Methods

index(arr:Arr, predicate:Any, start:Int=0, dflt:Any=[]) Source: stdlib.ngs:1919
Find index of first value that satisfies the predicate. TODO: Make it work on anything with each() method. In future, will throw exception if element is not found and default is not provided. Now returns null for backwards compatibilty in this case.

Parameters

arrItems to look at
predicateTest function
startIndex to start search at
dfltdefault value to return when element is not found

Returns

Int or dflt. Temporary also null, for backwards compatibilty.

Example

[1,2,11,3,4].index(X>10)  # 2