firstOrNull

Returns the first element, or null when this iterable is empty.


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

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


fun <T> List<T>.firstOrNull(): T?(source)

Returns the first element, or null when this list is empty.