allowing statements to be used as expressions
Rust allows most statements to be used as expressions.
let x = if isTrue {
println!("hi");
3
} else {
4
}
Swift allows statements to be used as expressions if they only contain a single expression in their bodies.
var isEnabled = switch {
case .enabled: true
default: false
}
In Haskell and many functional programming languages all control flow statements are expressions.
Generalization of if expressions.