Here's a sneaky little bug
Ali Çehreli
acehreli at yahoo.com
Fri Jun 24 12:02:10 PDT 2011
On Fri, 24 Jun 2011 14:49:24 -0400, Steven Schveighoffer wrote:
> On Fri, 24 Jun 2011 14:28:45 -0400, Andrej Mitrovic
>> writeln("state is: " ~ state ? "true" : "false");
> I can never remember precedence for ?:, so quite often I will
> over-parenthesize those expressions. I also typically over-parenthesize
> any expressions involving logical operations (i.e. & and |)
Yes!
> Rule of thumb -- minimal parentheses that establish order of precedence,
> even if unnecessary, don't ever hurt :)
And yes!
> I'd expect "state is: " ~ false to result in "state is: false"
bool is implicitly converted to char (as '\0' or '\1') and then the rest
is all valid.
Ali
More information about the Digitalmars-d
mailing list