takeEnd method

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

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

Implementation

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