In Java I can remove items from a list with this code:
private void filterList(List- items) {
Iterator
- iterator = items.iterator();
Kotlin has a lot of neat built-in functions. You can try to use filter here.
val filteredItems = items.filter { checkItem(it) }
Unfortunately, it will recreate the list. This API was designed on purpose to avoid extra mutability.
But if you still want to proceed with a MutableList use retainAll method
items.retainAll { checkItem(it) }