`data.groupBy { it[0] }.mapValues { (_, value) -&g...
# getting-started
m
data.groupBy { it[0] }.mapValues { (_, value) -> value.map { it[1] } }
👍 2
t
thanks, this language (and the slack channel) never disappoints
k
Why not
data.groupBy { it[0] }.mapValues { (_, value) -> value[1]}
?
a
Why not
data.groupBy({ it[0] }, { it[1] })
? 😉
k
Even better.
t
nice
that's perfect @arekolek, thanks
👍 1
i need the value to be an
Array<String>
rather than a
List<String>
though, where do i put that with this approach? 🤔
k
put
.toTypedArray()
at the end of the call
a
I guess that would be
data.groupBy({ it[0] }, { it[1] }).mapValues { it.value.toList() }
t
still more readable i think
Copy code
return data.groupBy(
    { it[0] },
    { it[1] }
).mapValues { it.value.toTypedArray() }
a
I read that wrong, I thought you needed a list, which it already was 😛
t
i wish i needed a list 😄
m
@arekolek nice one, I didn't know
groupBy
took more than one lambda