kotlin.collections.retainAll

retainAll

inline fun <T> MutableCollection<out T>.retainAll(
    elements: Collection<T>
): Boolean

Retains only the elements in this collection that are contained in the specified collection.

Allows to overcome type-safety restriction of retailAll that requires to pass a collection of type Collection<E>.

Return true if any element was removed from the collection, false if the collection was not modified.

fun <T> MutableIterable<T>.retainAll(
    predic