takeStart method

Option<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

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