groupBy

inline fun <K> CharSequence.groupBy(keySelector: (Char) -> K): Map<K, List<Char>>(source)

Groups characters of the original char sequence by the key returned by the given keySelector function applied to each character and returns a map where each group key is associated with a list of corresponding characters.

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

Since Kotlin

1.0

Samples


inline fun <K, V> CharSequence.groupBy(keySelector: (Char) -> K, valueTransform: (Char) -> V): Map<K, List<V>>(source)

Groups values returned by the valueTransform function applied to each character of the original char sequence by the key returned by the given keySelector function applied to the character and returns a map where each group key is associated with a list of corresponding values.

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

Since Kotlin

1.0

Samples