getRange method

Iterable<E> getRange(
  1. int start,
  2. int end
)

Returns an Iterable containing the first end elements of this, excluding the first start elements.

This method is a generalization of List.getRange to Iterables, and obeys the same contract.

Example:

{3, 8, 12, 4, 1}.range(2, 4); // [12, 4]

Implementation

Iterable<E> getRange(int start, int end) {
  RangeError.checkValidRange(start, end, this.length);
  return this.skip(start).take(end - start);
}