firstOrNull

inline fun firstOrNull(predicate: (element: E) -> Boolean): E?

Returns the first element in the collection for which predicate returns true or null if there are no elements that match predicate.

Return

The element for which predicate returns true or null if there are no elements in the set or predicate returned false for every element in the set.

Parameters

predicate

called with each element until it returns true.