until method

Iterable<int> until(
  1. int end, {
  2. int step = 1,
})

Returns a sequence of integer, starting from this, increments by step and ends at end

Implementation

Iterable<int> until(int end, {int step = 1}) sync* {
  if (step == 0) {
    throw RException.steps();
  }

  int currentNumber = this;

  if (step > 0) {
    while (currentNumber < end) {
      yield currentNumber;
      currentNumber += step;
    }
  } else {
    while (currentNumber > end) {
      yield currentNumber;
      currentNumber += step;
    }
  }
}