Kotlin HashSet associateWithTo()
Syntax & Examples


Syntax of HashSet.associateWithTo()

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

fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo( destination: M, valueSelector: (K) -> V ): M

This associateWithTo() extension function of HashSet populates and returns the destination mutable map with key-value pairs for each element of the given collection, where key is the element itself and value is provided by the valueSelector function applied to that key.