retainAll

fun retainAll(elements: Collection<*>): Boolean

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

In other words, removes from this list all of its elements that are not contained in the specified collection.

Return

true if this list changed as a result of the call.

See also

Parameters

elements

Collection containing elements to be retained in this list.

Throws

If the class of an element of this list is incompatible with the specified collection.

If this list contains a null element and the specified collection does not permit null elements.