Joffrey
12/06/2019, 10:50 AMMap<K, List<V>> from a List<Pair<K,V>> ?
I'm looking for the same thing as toMap(), but instead of discarding duplicate keys, it would aggregate the values in a list.
For now, I haven't found shorter than this trivial groupBy :
fun <K, V> List<Pair<K, V>>.toMapAggregate(): Map<K, List<V>> = groupBy(
{ (k, _) -> k },
{ (_, v) -> v }
)karelpeeters
12/06/2019, 10:51 AMval map = list.groupBy({ it.first }, { it.second })karelpeeters
12/06/2019, 10:51 AMJoffrey
12/06/2019, 10:51 AM