slice method

Iterable<T> slice(
  1. int from, [
  2. int? to
])

return sublist of range [from,to)

example

[a,b,c,d,e,f,g,h,i,j,k].slice(3,6) // => [d,e,f]

Implementation

Iterable<T> slice(int from, [int? to]) {
  if (to == null) {
    return skip(from);
  } else {
    return skip(from).take(to - from);
  }
}