Is there a way to do this: ```val fixture = listOf...
# announcements
d
Is there a way to do this:
Copy code
val fixture = listOf(
    mapOf(
        "a" to listOf(1,2,3),
        "b" to listOf(4)
    ),
    mapOf(
        "a" to listOf(5,6,7),
        "c" to listOf(8)
    )
)

// Should become
val result = mapOf(
  "a" to listOf(1,2,3,5,6,7),
  "b" to listOf(4),
  "c" to listOf(8)
)
d
Not sure if this is the best way, but that's what I came up with:
Copy code
fixture.flatMap { it.entries }
  .groupBy({ it.key }, { it.value })
  .mapValues { it.value.flatten() }
👍 5
m
I think that's an excellent way to get it done
d
Thanks,real nifty 😁!