Daniele B
08/10/2020, 11:42 PMdeactivateduser
08/10/2020, 11:49 PMDaniele B
08/10/2020, 11:54 PMlistA.removeIf { objA -> objA.field1 !in listB.map { it.field1 } }
the same of this?
listA.filter { objA -> objA.field1 in listB.map { it.field1 } }
deactivateduser
08/10/2020, 11:56 PMephemient
08/10/2020, 11:57 PMdeactivateduser
08/10/2020, 11:58 PMnanodeath
08/11/2020, 12:35 AMasSequence().map { it.field1 }.toSet()
, but I might like your way better...undecided 🙂Daniele B
08/11/2020, 12:41 AMval keepC = listB.mapTo(mutableSetOf()) { it.field1 }
equivalent to this?
val keepC = listB.map { it.field1 }.toSet()
Daniele B
08/11/2020, 12:44 AMlistA.retainAll { it.field1 in keepC }
and this ?
listA.filter { it.field1 in keepC }
nanodeath
08/11/2020, 12:45 AMlistB.map
) creates an intermediate list that you don't neednanodeath
08/11/2020, 12:46 AMlistA
, while the second one returns a new listDaniele B
08/11/2020, 12:47 AM