In Java I can remove items from a list with this code:
private void filterList(List- items) {
Iterator
- iterator = items.iterator();
This will remove even numbers from the list 1-9, and prints [1, 3, 5, 7, 9]
var myLists = mutableListOf(1,2,3,4,5,6,7,8,9)
myLists.removeAll{ it % 2 == 0 }
println(myLists)
This will retain even numbers and remove others from the list 1-9, and prints [2, 4, 6, 8]
myLists = mutableListOf(1,2,3,4,5,6,7,8,9)
myLists.retainAll{ it % 2 == 0 }
println(myLists)
Try them in https://play.kotlinlang.org/