lastOrNull

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


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

Returns the last matching element after traversing this iterable in iteration order.


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

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


inline fun <T> List<T>.lastOrNull(predicate: (T) -> Boolean): T?(source)

Returns the last matching element, searching from the end until a match is found.