Function popBackN

Removes maximum count last elements from the bidirectional range range.

void popBackN(R) (
  ref R range,
  size_t count
)
if (isBidirectionalRange!R);

Parameters

NameDescription
R Range type.
range Some bidirectional range.
count Number of elements to remove.

See Also

popFrontN, popBackExactly, isBidirectionalRange.

Example

int[5] a = [1, 2, 3, 4, 5];
auto slice = a[];

popBackN(slice, 3);
assert(slice.length == 2);
assert(slice[0] == 1);
assert(slice[$ - 1] == 2);

popBackN(slice, 20);
assert(slice.length == 0);