https://kotlinlang.org logo
l

liminal

01/03/2021, 6:32 PM
I have 2 lists holding the same data type that has unique “id” property. One is a bigger list that serves as a single source of truth and the other is a sublist. After the big list gets updated, how can I go through the smaller list and update values present there from the bigger list when “id” matches?
Just realized that there is intersect available for Set collections but still need to use a predicate (“id” match)
j

jbnizet

01/03/2021, 8:13 PM
I would transform the bigger list into a Map<id, Data> (using associate), then I would loop over the small list, for each element, find the matching one in the bigger list, and update.
🙏 1
4 Views