8 ms·
I'm the accidental maintainer/guardian/dungeon keeper of a bunch of scary code at work, which happily does: if (false != aBooleanVariable) I still can't p
by unwind 10y ago
I'm the accidental maintainer/guardian/dungeon keeper of a bunch of scary code at work, which happily does:
if (false != aBooleanVariable)
I still can't parse that without stopping and thinking (and sometimes cursing the original author). To me, with booleans, this can only sanely be written:
if (aBooleanVariable)
Code with literals is often worse than functionally equivalent code without; literals are complexity. And I hate literal comparisons with true and false for booleans. Aargh.
- dozzie 10y agoI thought up at some point something like this: return (aBoolean != false) ? false : true; So ridiculous that it made me laugh.
- pythonaut_16 10y agoThe downside in a dynamically typed language is that if (aBooleanVariable) will return true for any truthy value, not just 'True'. Of course I still prefer writing my if statements that way, it's just something you have to watch for if something does go wrong.