On Friday, 13 February 2015 at 09:38:04 UTC, Dennis Ritchie wrote:
This is a bug?import std.stdio; void main() { int a = 0; writeln( (a < 10) ? a = 1 : a = 2 ); // prints 2 writeln( (a < 10) ? a = 1 : (a = 2) ); // prints 1 } Even C++ output: 1 1
About 2 years ago, I had a problem with similar structure. My guess is that the first one is accepted as this. ((a < 10) ? a = 1 : a) = ( 2 )Thereby it gives this result. Vague definitions are always error prone.