3 ms·
> In my mind, an if/else block is an imperative entity that describes two different actions that could happen. Even if in reality both branches are trivial, my
by nicoburns 6y ago
> In my mind, an if/else block is an imperative entity that describes two different actions that could happen. Even if in reality both branches are trivial, my mind will be unnecessarily occupied with the fact that it needs to reason about code here, not just data
That's true in some languages. But in some languages if-else can also be used as in expression. e.g. in Rust I can write:
let foo = if condition { "FOO" } else { "BAR" }
- gpderetta 6y ago... which is equivalent to a ternary, hence the thesis.