skip method

  1. @override
Iterable<E> skip(
  1. int count
)
override

Creates an Iterable that provides all but the first count elements.

When the returned iterable is iterated, it starts iterating over this, first skipping past the initial count elements. If this has fewer than count elements, then the resulting Iterable is empty. After that, the remaining elements are iterated in the same order as in this iterable.

Some iterables may be able to find later elements without first iterating through earlier elements, for example when iterating a List. Such iterables are allowed to ignore the initial skipped elements.

Example:

final numbers = <int>[1, 2, 3, 5, 6, 7];
final result = numbers.skip(4); // (6, 7)
final skipAll = numbers.skip(100); // () - no elements.

The count must not be negative.

Implementation

@override
Iterable<E> skip(int count) {
  if (count >= length) {
    return const Iterable.empty();
  }
  return _SubRangeIterable(this, count);
}