Kotlin HashSet onEachIndexed()
Syntax & Examples


Syntax of HashSet.onEachIndexed()

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

fun <T, C : Iterable<T>> C.onEachIndexed( action: (index: Int, T) -> Unit ): C

This onEachIndexed() extension function of HashSet performs the given action on each element, providing sequential index with the element, and returns the collection itself afterwards.