bug in grammar with ?:
Adam D. Ruppe
destructionator at gmail.com
Tue Sep 17 18:11:08 UTC 2019
On Tuesday, 17 September 2019 at 18:03:20 UTC, Brett wrote:
> for(ulong i = len - 1; i >= (true) ? 0 : 1; i--)
> for(ulong i = len - 1; i >= ((true) ? 0 : 1); i--)
Those are two different things by design. The >= binds more
tightly than the ?:, it lets you do stuff like
a > 0 ? "greater than" : "not greater than"
Thus the first one is more like
if(i >= (true)) {
return 0;
} else {
return 1; {
}
and the second one is
if(i >= ((true) ? 0 : 1)
Though I personally like to use extra parens though just remember
that true and (true) are no different, regardless of context -
those parens are totally redundant..
More information about the Digitalmars-d
mailing list