take method

  1. @override
RIterator<T> take(
  1. int count
)
override

Creates a lazy iterable of the count first elements of this iterable.

The returned Iterable may contain fewer than count elements, if this contains fewer than count elements.

The elements can be computed by stepping through iterator until count elements have been seen.

The count must not be negative.

Example:

final numbers = <int>[1, 2, 3, 5, 6, 7];
final result = numbers.take(4); // (1, 2, 3, 5)
final takeAll = numbers.take(100); // (1, 2, 3, 5, 6, 7)

Implementation

@override
RIterator<T> take(int count) =>
    RIterator(_list.getRange(_start, _end).take(count).iterator);