4 ms·
The significant difference is that in Rust, like in Lisp, `if` is an expression, so if-else essentially is the ternary operator. const x = cond1 ? a
by kbp 7y ago
The significant difference is that in Rust, like in Lisp, `if` is an expression, so if-else essentially is the ternary operator.
const x = cond1 ? a
: cond2 ? b
: c
becomes in Rust
let x = if cond1 { a }
else if cond2 { b }
else { c }