On 19/09/2017 9:22 PM, Neia Neutuladh wrote:
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.
Agreed, no surprises is the best surprise!