advanceBy method

  1. @override
Result<(), int> advanceBy(
  1. int n
)

Advances the iterator by n elements. The iterator will have been advanced by n elements when Ok(()) is returned, or a Err(k) where k is remaining number of steps that could not be advanced because the iterator ran out.

Implementation

@override
Result<(), int> advanceBy(int n) {
  for (var i = 0; i < n; i++) {
    if (!moveNext()) {
      return Err(n - i);
    }
  }
  return Ok(());
}