So what does (inout int = 0) do?

Nick Treleaven via Digitalmars-d digitalmars-d at puremagic.com
Fri Apr 15 05:59:39 PDT 2016


On Friday, 15 April 2016 at 04:23:29 UTC, Jonathan M Davis wrote:
> Certainly, there have been a few times that it's come up in 
> D.Learn when folks ask what the heck it is, so there should be 
> a few posts floating around with an explanation. This is the 
> only useful post that I could find in a quick search though:
>
> http://forum.dlang.org/post/mh68p8$2p56$1@digitalmars.com

He says:
> Alternatively, you could have the lambda take an R as a 
> parameter. Or fix the semantics ...

Assuming it works OK, that seems much cleaner:

(R r)
{
     if (r.empty) {}
     ...
}




More information about the Digitalmars-d mailing list