sublist method

List<E> sublist (int start, [ int end ])

Returns a new list containing the objects from start inclusive to end exclusive.

List<String> colors = ['red', 'green', 'blue', 'orange', 'pink'];
colors.sublist(1, 3); // ['green', 'blue']

If end is omitted, the length of this is used.

colors.sublist(1);  // ['green', 'blue', 'orange', 'pink']

An error occurs if start is outside the range 0 .. length or if end is outside the range start .. length.

Implementation

List<E> sublist(int start, [int end]);