3 ms·
That's a ternary, not an if expression.
by rdw 11y ago
That's a ternary, not an if expression.
- emn13 11y agoThe difference being?
- kazagistar 11y agoYou can not have full blocks, only expressions.
- emn13 11y agoAnd in an if-expression, you similarly can have expressions. Some of those expressions might be blocks. Some languages restrict where block expressions can be placed, but that's not a meaningful difference between if expressions and ternaries, that's a difference how blocks are treated. More concretely: I know of no language that allows "if expressions" that aren't just ternaries (i.e. either the language allows blocks as expressions or it doesn't, but given that choice, no language then further distinguishes between if expressions and ternaries).