def
func:find
find(val, fn)
Find the first matching item in a list or grid by applying the given filter function. If no match is found return null.
If working with a list, the filter should be a function that takes (val)
or (val, index)
. It should return true to match and return the item.
If working with a dict, the filter should be a function that takes (val)
or (val, name)
. It should return true to match and return the item.
If working with a grid, the filter function takes (row)
or (row, index)
and returns true to match and return the row.
If working with a stream, the filter takes (val)
and returns true to match. See Streams.
Examples:
// find first string longer than 3 chars ["ape", "bat", "charlie", "dingo"].find(x => x.size > 3) // find first odd number [10, 4, 3, 7].find(isOdd)