If Expression
Like Rust, if
statements can also be used as expressions, replacing the ? :
conditional
operators in other C-like languages.
if
expressions can be disabled via Engine::set_allow_if_expression
.
// The following is equivalent to C: int x = 1 + (decision ? 42 : 123) / 2;
let x = 1 + if decision { 42 } else { 123 } / 2;
x == 22;
let x = if decision { 42 }; // no else branch defaults to '()'
x == ();