What the hell is wrong with D?
    Neia Neutuladh 
    neia at ikeran.org
       
    Tue Sep 19 20:22:25 UTC 2017
    
    
  
On Tuesday, 19 September 2017 at 17:40:20 UTC, EntangledQuanta 
wrote:
>
> 	writeln(x + ((_win[0] == '@') ? w/2 : 0));
> 	writeln(x + (_win[0] == '@') ? w/2 : 0);
>
> The first returns x + w/2 and the second returns w/2!
Yeah, it sucks to have bugs like this crop up. I have enough 
trouble remembering operator precedence, so I end up using 
parentheses everywhere and pretending the ternary operator 
doesn't exist. I also tend to break up complex expressions a lot. 
It's just safer, and usually clearer.
    
    
More information about the Digitalmars-d-learn
mailing list