dropRight method

  1. @override
IList<A> dropRight(
  1. int n
)
override

Return a new collection with the last n elements removed.

Implementation

@override
IList<A> dropRight(int n) {
  if (isEmpty) {
    return this;
  } else {
    final lead = iterator.drop(n);
    final it = iterator;

    final res = builder<A>();

    while (lead.hasNext) {
      res.addOne(it.next());
      lead.next();
    }

    return res.toIList();
  }
}