intersect method

  1. @useResult
KtSet<T> intersect(
  1. KtIterable<T> other
)

Returns a set containing all elements that are contained by both this set and the specified collection.

The returned set preserves the element iteration order of the original collection.

Implementation

@useResult
KtSet<T> intersect(KtIterable<T> other) {
  final set = toMutableSet();
  set.retainAll(other);
  return set;
}