Array.removeBack - multiple declarations

Function Array.removeBack

Removes the value at the back of the array.

void removeBack();

Returns

The number of elements removed

Precondition

!empty.

Function Array.removeBack

Removes howMany elements from the array.

size_t removeBack (
  size_t howMany
);

This method doesn't fail if it could not remove howMany elements. Instead, if howMany is greater than the array length, all elements are removed.

Parameters

NameDescription
howMany How many elements should be removed.

Returns

The number of elements removed

Example

auto v = Array!int([5, 18, 17]);

assert(v.removeBack(0) == 0);
assert(v.removeBack(2) == 2);
assert(v.removeBack(3) == 1);
assert(v.removeBack(3) == 0);