mapWhere method

Iterable<T> mapWhere(
  1. bool predicate(
    1. T
    ),
  2. T replace(
    1. T
    )
)

Returns an Iterable that replaces elements that do not satisfy predicate with the new element returned by replace.

Implementation

Iterable<T> mapWhere(bool Function(T) predicate, T Function(T) replace) sync* {
  for (final element in this) {
    if (predicate(element)) {
      yield replace(element);

    } else {
      yield element;
    }
  }
}