W3cubDocs

/Kotlin

associateByTo

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
inline fun <K, M : MutableMap<in K, in Char>> CharSequence.associateByTo(
    destination: M, 
    keySelector: (Char) -> K
): M

Populates and returns the destination mutable map with key-value pairs, where key is provided by the keySelector function applied to each character of the given char sequence and value is the character itself.

If any two characters would have the same key returned by keySelector the last one gets added to the map.

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
inline fun <K, V, M : MutableMap<in K, in V>> CharSequence.associateByTo(
    destination: M, 
    keySelector: (Char) -> K, 
    valueTransform: (Char) -> V
): M

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 characters of the given char sequence.

If any two characters would have the same key returned by keySelector the last one gets added to the map.

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