except method
Yields elements from this iterable that are not present in the elements iterable.
Iterates over each element in the current iterable. If an element is not found
in the provided elements iterable, it is yielded.
Parameters: elements (Iterable
Returns: Iterable
Example:
List<int> numbers = [1, 2, 3, 4, 5];
List<int> exclude = [2, 3];
Iterable<int> result = numbers.except(exclude); // Yields [1, 4, 5]
Note: The returned iterable is lazy. Elements are only processed when they are iterated over.
Implementation
Iterable<T> except(Iterable<T> elements) sync* {
for (var current in this) {
if (!elements.contains(current)) {
yield current;
}
}
}