4 ms·
You can not have full blocks, only expressions.
by kazagistar 11y ago
You 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).