What stdlib function turns `foo` into `bar`? ```v...
# getting-started
h
What stdlib function turns
foo
into
bar
?
Copy code
val foo = listOf(
  'a' to 1,
  'a' to 2,
  'b' to 3
)

val bar = mapOf(
  'a' to listOf(1, 2),
  'b' to listOf(3)
)
UPDATE: I found the answer
Copy code
fun <T, K, V> Iterable<T>.groupBy(
    keySelector: (T) -> K,
    valueTransform: (T) -> V
): Map<K, List<V>>
a
foo.associateBy{} ?
h
that returns
Map<Char, Int>
instead of the desired
Map<Char, List<Int>>
d
foo.groupBy { it.first }
?
h
that returns
Map<Char, List<Pair<Char, Int>>>
i think it's just associate
nope, that doesn't do it
oh, it's
Copy code
foo.groupBy({ it.first }, { it.second })
a
nice!
I was going down the road of
reduce
lol