Simultaneous Assignment

Andrea Fontana nospam at example.com
Tue Dec 10 13:15:49 PST 2013


On Monday, 9 December 2013 at 13:57:04 UTC, qznc wrote:
>   int x;
>   if((x = some_long_expression.here) > 0) {
>     writefln("x is %s", x);
>   }
>
> The bad news is that this means type inference cannot be used 
> here (no "auto") and the variables is declared in a wider scope 
> than just the if-body.

Ok then write:

{
   auto x = some_long_expression.here;
   if (x > 0) {
     writefln("x is %s", x);
   }
}



More information about the Digitalmars-d-learn mailing list