whereNot method

Iterable<T> whereNot(
  1. bool predicate(
    1. T element
    )
)

Yields all elements of the iterable for which the predicate returns false.

This function iterates over the elements of the iterable. For each element, it checks the given predicate function. If the predicate returns false, the element is yielded. Essentially, it filters out elements for which the predicate returns true.

Parameters: predicate (Function(T element)): A function that takes an element as input and returns a boolean. If it returns false, the element is included in the result.

Returns: Iterable

Example:

List<int> numbers = [1, 2, 3, 4, 5];
Iterable<int> nonEvenNumbers = numbers.whereNot((n) => n % 2 == 0); // Yields [1, 3, 5]

Note: The returned iterable is lazy. Elements are only processed when they are iterated over.

Implementation

Iterable<T> whereNot(bool predicate(T element)) sync* {
  for (var element in this) {
    if (!predicate(element)) {
      yield element;
    }
  }
}