if Expressions
202307071943
Status: #idea
Tags: Rust
if Expressions
Info
Condition must be a boolean. Rust does NOT auto convert non-booleans to booleans
let n = 3;
;
if n > 5 {
println!("true");
} else {
println!("false");
}
Using if in a let statement
let number = if condition { 5 } else { 6 };
let number = if condition { 5 } else { "six" }; // Error