next method Null safety

E next()

Implementation

E next() {
  // Call to hasNext is necessary to make sure we are positioned at the first
  // element when we start iterating.
  if (!hasNext) throw StateError("No more elements");
  assert(_state == _HAS_NEXT_AND_NEXT_IN_CURRENT);
  E result = _iterator.current;
  _move();
  return result;
}