takeStart method

Slice<T>? takeStart(
  1. int to
)

Returns a new slice of this slice until to, and removes those elements from this slice. Returns None and does not modify the slice if the given range is out of bounds.

Implementation

Slice<T>? takeStart(int to) {
  if (to < 0 || to > _end - _start) {
    return null;
  }
  var slice = Slice<T>(_list, _start, _start + to);
  _start += to;
  return slice;
}