SList: How do I use linearRemove?

Lemonfiend via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Jun 26 09:50:36 PDT 2014


> unittest
> {
>     auto s = SList!int(1, 2, 3, 4, 5);
>     auto r = s[];
>     popFrontN(r, 3);
>     auto r1 = s.linearRemove(r);
>     assert(s == SList!int(1, 2, 3));
>     assert(r1.empty);
> }

This works:
auto s = SList!int(1, 2, 3, 4, 5);
auto r = s[];
popFrontN(r, 1);
auto r1 = s.linearRemove(r);

This doesn't (why?):
auto s = SList!int(1, 2, 3, 4, 5);
auto r = s[];
auto r1 = s.linearRemove(r);

This doesn't (why?):
auto s = SList!int(1, 2, 3, 4, 5);
auto s2 = SList!int(1, 2, 3, 4, 5);
auto r = s2[];
popFrontN(r, 1);
auto r1 = s.linearRemove(r);

I am at a loss..


More information about the Digitalmars-d-learn mailing list