takeEnd method

Option<Slice<T>> takeEnd(
  1. int from
)

Returns a new slice of this slice from the end, 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>> takeEnd(int from) {
  if (from < 0 || from > _end - _start) {
    return None;
  }
  var slice = Slice<T>(_list, _end - from, _end);
  _end -= from;
  return Some(slice);
}