In Rust, I have noticed that everything is an expression except 2 kinds of statements. Every expression that adds ;
will become a statement. Rust's grammar wants statements to follow other statements.
So why don't we add ;
at the end of an if
/ else
"expression"? This is also an expression, so why don't we do this:
if true {
println!("true");
} else {
println!("false");
};
Aucun commentaire:
Enregistrer un commentaire