intersect method
Return the intersection of two Iterable (all the elements that both Iterable have in common).
If an element occurs twice in this iterable, it occurs twice in the
result, but if it occurs twice in iterable
, only the first value
is used.
Implementation
Iterable<T> intersect(Iterable<T> iterable) sync* {
// If it's not important that [iterable] can change between
// `element`s, consider creating a set from it first,
// for faster `contains`.
for (var element in this) {
if (iterable.contains(element)) yield element;
}
}