Hey everyone, very basic question but I can’t figu...
# announcements
a
Hey everyone, very basic question but I can’t figure out if there’s a native kotlin function to do something like this where I want to get a list of the numbers in originalNumbers that are not in newNumbers
Copy code
val originalNumbers = listOf(1,3,5,6,8,235,764)
val newNumbers = listOf(1,4,6,235,764,23)
val toRemove = originalNumbers.filter { it !in newNumbers } // [3, 5, 8]
This work perfectly fine, but just for my own peace of mind I feel like there’s a collections functions that would do exactly that?
If they have a proper
equals
implementation, you can subtract two iterables.
a
Oh god this is so simple! Yes this was exactly what I wanted, thanks!
👍 1