Is there an idiomatic way to diff between two list...
# announcements
k
Is there an idiomatic way to diff between two lists, based on some value? I tried to use the minus opertaor and it gave the first one as the diff too. Do not want that
j
list1.filter { a -> !list2.contains(a) } ?
Need to do reverse also and combine. Might be easier way though 🤔
k
Found this on SO, seems to work well.
Copy code
val sum = ogList + newList
	val ans =  sum.groupBy { it.id }
    				.filter { it.value.size == 1 }
    				.flatMap { it.value }
🎉 1
j
If data is large may want to use sequence