find

inline fun <T> Iterable<T>.find(predicate: (T) -> Boolean): T?(source)

Returns the first matching element, or null when no element matches predicate.

An alias for firstOrNull with a predicate; stops at the first match. For nullable elements, a null result may also be a selected null element. Exceptions from iteration or the callback propagate to the caller. The inline callback supports non-local returns.

Receiver

elements to visit in their iteration order.

Return

the first accepted element, or null when empty or unmatched.

Parameters

predicate

test returning true to select an element.

See also