3 ms·
In C style languages you have the ?: operator though, which is basically if as an expression.
by olavk 9y ago
In C style languages you have the ?: operator though, which is basically if as an expression.
- dragonwriter 9y agoFunctionally, 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.