Re: Simultaneous Assignment

2013-12-10 Thread Andrea Fontana
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

Re: Simultaneous Assignment

2013-12-09 Thread qznc
On Monday, 9 December 2013 at 07:38:04 UTC, Dfr wrote: Does D has somtething similar ? http://code.google.com/p/go-wiki/wiki/SimultaneousAssignment No, not in general. There are a few special cases, though. The foreach loop can assign value and index simultaneously. foreach (int i, char

Re: Simultaneous Assignment

2013-12-09 Thread Dfr
Sorry, it was misnomer in topic title. But simultaneous assignment also useful topic to learn. What i trying to achieve in my current example is more succinct code. A coming from Perl and instead of writing: if(some_complex_statement.here 0) { writefln(x is %s

Re: Simultaneous Assignment

2013-12-09 Thread qznc
On Monday, 9 December 2013 at 09:32:26 UTC, Dfr wrote: What i trying to achieve in my current example is more succinct code. A coming from Perl and instead of writing: if(some_complex_statement.here 0) { writefln(x is %s, some_long_expression.here); } I got used not to repeat complex

Simultaneous Assignment

2013-12-08 Thread Dfr
Does D has somtething similar ? http://code.google.com/p/go-wiki/wiki/SimultaneousAssignment I tried this way, but it not worked out. if((int x = 10) 0) { writefln(x is %s, x); }