Kotlin HashSet lastOrNull()
Syntax & Examples


Syntax of HashSet.lastOrNull()

There are 2 variations for the syntax of HashSet.lastOrNull() extension function. They are:

1.
fun <T> Iterable<T>.lastOrNull(): T?

This extension function returns the last element, or null if the collection is empty.

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

This extension function returns the last element matching the given predicate, or null if no such element was found.