Function Vector.pop

Move the element at position pos out of vector, effectively reducing its length by 1.

Vector.ElementType pop (
  const size_t pos,
  Vector.ElementType def = ElementType.init
) nothrow scope;

Return erased element.

If pos is invalid then return def or ElementType.init.

Examples

Vector!(int, 6) vec = Vector!(int, 6).build(1, 2, 3, 4, 5);
assert(vec.length == 5);

assert(vec.pop(0) == 1);
assert(vec == [2, 3, 4, 5]);

assert(vec.pop(3) == 5);
assert(vec == [2, 3, 4]);

assert(vec.pop(1) == 3);
assert(vec == [2, 4]);