What is the best way to associate by to a list if ...
# getting-started
f
What is the best way to associate by to a list if key is present multiple times
Copy code
associateBy(keySelector = { it.getAttributeValue(“name”) }, valueTransform = { it.getAttributeValue(“value”) ?: “” })
m
What do you want to do if the key is there multiple times?
f
I want the value to be a list of all values
k
I think you want
groupBy
m
You could probably use
groupBy
, or
groupingBy
if you want to avoid immediate collections.
f
thanks @kevinmost @marstran
👍 1
it’s perfect