method
getRange

Iterable<E> getRange(
int start,
int end
)

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

An error occurs if [end] is before [start].

An error occurs if the [start] and [end] are not valid ranges at the time of the call to this method. The returned [Iterable] behaves like skip(start).take(end - start). That is, it does not throw exceptions if this changes size.

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