getAndPopBack

Returns the last element and removes it from the range.

If range has lvalue elements, then $(D_PSYMBOL getAndPopBack) returns by reference, otherwise the returned element is copied.

ref
getAndPopBack
(
R
)
(
ref R range
)

Parameters

R

Bidirectional range type.

range R

Bidirectional range.

Return Value

Type: auto ref

Last range element.

Examples

int[3] array = [1, 2, 3];
auto slice = array[];

assert(getAndPopBack(slice) == 3);
assert(slice.length == 2);

See Also

$(D_PSYMBOL getAndPopFront).

Meta