eatOne

Returns the first element in the range r and pops then next

@safe
T
eatOne
(
Range
T = ElementType!Range
)
(
ref Range r
,
T default_value = T.init
)
if (
isInputRange!Range
)

Parameters

r Range

range

Return Value

Type: T

r.front

Examples

/

const(int)[] a = [1, 2, 3];
assert(eatOne(a) == 1);
assert(eatOne(a) == 2);
assert(eatOne(a) == 3);
assert(a.empty);
assert(eatOne(a, -1) == -1);
assert(eatOne(a) == int.init);