forEachWhile method

void forEachWhile(
  1. bool action(
    1. T element
    )
)

Takes an action for each element as long as desired.

Calls action for each element. Stops iteration if action returns false.

Implementation

void forEachWhile(bool Function(T element) action) {
  for (var element in this) {
    if (!action(element)) break;
  }
}