Should this work?
Peter Alexander
peter.alexander.au at gmail.com
Fri Jan 10 09:10:27 PST 2014
On Friday, 10 January 2014 at 14:02:21 UTC, Manu wrote:
> What's the go with popFront()... it returns nothing?
> I almost always want to pop and return the front element. I
> can't find a
> function to do that... have I missed something again?
popFront just pops the front element off the range.
int[] a = [1, 2, 3];
a.popFront();
assert(a == [2, 3]);
If you want to first element, just use front.
int[] a = [1, 2, 3];
int x = a.front;
a.popFront();
assert(a == [2, 3] && x == 1);
Warning, x has mutable references, it won't necessarily be valid
after a call to popFront and an input range (e.g. byLine).
More information about the Digitalmars-d
mailing list