std.algorithm each documentation terse

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jul 20 08:12:24 PDT 2015


On Monday, 20 July 2015 at 15:08:16 UTC, Nicholas Wilson wrote:
> But the lambda takes a ref parameter...

Yes, but it never writes to it:

     x.each!((ref a) => a + 1);

Instead, this should work:

     x.each!((ref a) => a = a + 1);

... as a short-hand for:

     x.each!((ref a) { a = a + 1; });


More information about the Digitalmars-d-learn mailing list