removeIf

inline fun <T> MutableIterable<T>.removeIf(noinline predicate: (T) -> Boolean): Boolean(source)

Removes, from an iterable, every element that satisfies the provided predicate.

Removals may or may not happen immediately as each element is tested against the predicate. The behavior of this method is not specified if predicate is dependent on this.

Java 8 users: if this is a Collection, use this.removeIf(predicate) instead.

Return

true if any elements were removed from the iterable

See also

Parameters

predicate

a predicate that determines whether an element should be removed


inline fun <T> MutableIterator<T>.removeIf(noinline predicate: (T) -> Boolean): Boolean(source)

Removes every element that satisfies the provided predicate from the iterator. The iterator will be left exhausted: its hasNext method will return false.

Return

true if any elements were removed from the this

See also

Parameters

predicate

a predicate that determines whether an element should be removed