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