Re:Sizeof(char) is 1
by rix0r on Monday September 06, 2010 @05:29AM
(#1666323)
Which is actually pretty useful and readable, imho (if formatted correctly):
Side note: this does not work in PHP, as the operator is left-associative instead of right-associative there. The above in PHP would be evaluated as:
Which is almost never what you want. I can't even format this properly to convey intent.
[ Parent
| on HN ]
The only sane thing is to use if statements, imho. No ninja cowboy engineer nonsense.
Correct bracketing would be plenty in this case. If-statements sometimes (not always) make code much less readable than ternary operations.
This is why more languages should adopt the every-form-returns-a-value paradigm.
Sometimes, if-statements unnecessarily add lines, and the lines become harder to read.
I would say it's a case-by-case statement. Well, okay, more specifically, I would say that the use of a single ternary if is a case-by-case statement.