Kotlin HashSet associateByTo()
Syntax & Examples
Syntax of HashSet.associateByTo()
There are 2 variations for the syntax of HashSet.associateByTo() extension function. They are:
1.
fun <T, K, M : MutableMap<in K, in T>> Iterable<T>.associateByTo( destination: M, keySelector: (T) -> K ): M
This extension function populates and returns the destination mutable map with key-value pairs, where key is provided by the keySelector function applied to each element of the given collection and value is the element itself.
2.
fun <T, K, V, M : MutableMap<in K, in V>> Iterable<T>.associateByTo( destination: M, keySelector: (T) -> K, valueTransform: (T) -> V ): M
This extension function populates and returns the destination mutable map with key-value pairs, where key is provided by the keySelector function and and value is provided by the valueTransform function applied to elements of the given collection.