if-else returns a value
- This expersssion must have an
else
part! - The last statement in both the
if
and theelse
part has no;
at the end and thus they are calledexpressions
and notstatements
.
fn main() { let x = 1; let y = 2; let z = if x < y { x + y } else { x * y }; println!("{z}"); }