News for hackers. Stuff that matters.
Re:Avoid Else, Return Early (2013) by olavk on Monday March 26, 2018 @11:57AM (#16679811)
In C style languages you have the ?: operator though, which is basically if as an expression.
Re:Avoid Else, Return Early (2013) by dragonwriter on Monday March 26, 2018 @12:47PM (#16680268)
Functionally, yes, in terms of readability, not really. But, yes, for really simple cases like the example under discussion:

  return (a>=b) ? a : b
is probably the best option in those languages. The level of complexity at which the C ternary operator ceases to be ideal, I think, is lower than that of expression-if.