W3cubDocs

/Kotlin

associateBy

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
inline fun <K> CharSequence.associateBy(
    keySelector: (Char) -> K
): Map<K, Char>

Returns a Map containing the characters from the given char sequence indexed by the key returned from keySelector function applied to each character.

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

The returned map preserves the entry iteration order of the original char sequence.

Platform and version requirements: JVM (1.0), JS (1.0), Native (1.0)
inline fun <K, V> CharSequence.associateBy(
    keySelector: (Char) -> K, 
    valueTransform: (Char) -> V
): Map<K, V>

Returns a Map containing the values provided by valueTransform and indexed by keySelector functions 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.

The returned map preserves the entry iteration order of the original char sequence.

© 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.html