Kotlin HashSet associateWith()
Syntax & Examples


Syntax of HashSet.associateWith()

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

fun <K, V> Iterable<K>.associateWith( valueSelector: (K) -> V ): Map<K, V>

This associateWith() extension function of HashSet returns a Map where keys are elements from the given collection and values are produced by the valueSelector function applied to each element.