getRange method

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

Returns an Iterable that iterates over the objects in the range start inclusive to end exclusive.

The provided range, given by start and end, must be valid, which means 0 <= start <= end <= len, where len is this list's length. The range starts at start and has length end - start. An empty range (with end == start) is valid.

The returned Iterable behaves like skip(start).take(end - start).

final IList<String> colors = ['red', 'green', 'blue', 'orange', 'pink'].lock;
final Iterable<String> range = colors.getRange(1, 4);
range.join(', ');  // 'green, blue, orange'

This method exists just to make the IList API more similar to that of the List, but to get a range here you should probably use the IList.sublist() method instead.

Implementation

Iterable<T> getRange(int start, int end) {
  // TODO: Still need to implement efficiently.
  return toList(growable: false).getRange(start, end);
}