I want to combine two object lists. Each object has a specific id. If the same object exists in two lists, I want to merge them. And if a value is null I want to get the non-null one. For example:
val list1 = listOf(
Object(id = 1, hello, 100),
Object(id = 2, null, 40)
)
val list2 = listOf(
Object(id = 1, null, 100),
Object(id = 2, test, 40),
Object(id = 3, hi, 13)
)
The result I want to achieve is as follows:
val result = listOf(
Object(id = 1, hello, 100),
Object(id = 2, test, 40),
Object(id = 3, hi, 13)
)
NOTE: if a value is not empty I know it is not different.