3 ms·
Block-oriented languages can do it; Rust, for example: let result = if boolean_flag { do_this() } else { do_that() }; Rust actually doesn’t
by chrismorgan 9y ago
Block-oriented languages can do it; Rust, for example:
let result = if boolean_flag {
do_this()
} else {
do_that()
};
Rust actually doesn’t have a ternary operator.
- lmm 9y agoWhat do you mean "block-oriented"? I'd say this is part of Rust's ML heritage, and comes of being expression-oriented: if is just an expression, and evaluates to a value like any other expression.
- nerdponx 9y agoMaybe "block oriented" is supposed to mean "has blocks that are expressions".
- deleted 9y ago[deleted]
- chrismorgan 9y agoSorry, “expression-oriented” was what I meant to write.