Kotlin HashSet elementAtOrElse()
Syntax & Examples


Syntax of HashSet.elementAtOrElse()

The syntax of HashSet.elementAtOrElse() extension function is:

fun <T> Iterable<T>.elementAtOrElse( index: Int, defaultValue: (Int) -> T ): T

This elementAtOrElse() extension function of HashSet returns an element at the given index or the result of calling the defaultValue function if the index is out of bounds of this collection.