data class AttachmentItem(val imageId: String, val extension: String)
now I have two lists of these attachments:
Copy code
val list1 = listOf<AttachmentItem>()
val list2 = listOf<AttachmentItem>()
//now I want to know which AttachmentItems are missing in list1 but are there in list 2 and vice versa. So:
val diff1 = //attachments available in list1 but not in list2
val diff2 = //attachments available in list2 but not in list1
How would I do that in kotlin?
j
Jacob
04/29/2022, 2:11 PM
diff1 = list1 - list2
m
Michael de Kaste
04/29/2022, 2:14 PM
what Jacob said. Although, if you work with data classes you might be wanting to type list1 and list2 as sets instead, guarantees uniqueness (why would you have two images with the same ID and extension?) and makes the difference checks of