What is the best way to filter out a list of objects with a list of properties of the given object.
Here is the sample code that shows what I'm trying to achieve:
data class Person(
val id: Long = 0,
val name: String = ""
)
fun filterOutList(): List<Person>{
val idsToRemove = listOf(1, 3)
val listToFilter = listOf(
Person(1, "John"),
Person(2, "Jane"),
Person(3, "Bob"),
Person(4, "Nick")
)
// expecting to get a list only with Objects that have ids 2 and 4
return listToFilter.filter { ??? provide `idsToRemove` to get only what was not in the list }
}