Kotlin HashSet first()
Syntax & Examples


Syntax of HashSet.first()

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

1.
fun <T> Iterable<T>.first(): T

This extension function returns the first element.

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

This extension function returns the first element matching the given predicate.