Hi folks! :wave: Imagine a list A ```[{id: 1, isSo...
# android
n
Hi folks! 👋 Imagine a list A
Copy code
[{id: 1, isSomething: false},{id: 2, isSomething: false}]
and list B
Copy code
[{id: 1, isSomething: true}]
Is there an easy nice clean way in kotlin to merge the two lists so it ends up favoring list B ending up giving me
Copy code
{id: 1, isSomething: true},{id: 2, isSomething: false}]
😶 1
K 1
e
assuming no duplicate IDs within either list,
Copy code
(listA.groupBy { it.id } + listB.groupBy { it.id }).values.map { it.single() }
🙌 1
n
Thank you that's perfect! 🙏