W3cubDocs

/Kotlin

associateWithTo

Platform and version requirements: JVM (1.3), JS (1.3), Native (1.3)
inline fun <K, V, M : MutableMap<in K, in V>> Iterable<K>.associateWithTo(
    destination: M, 
    valueSelector: (K) -> V
): M

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.

If any two elements are equal, the last one overwrites the former value in the map.

© 2010–2019 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.
https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/associate-with-to.html