Functions
fn definition, parameter/return types, and implicit return of the last expression.
Simple enough for a 5-year-old to understand
fn and return
Parameter types use :, return types use ->. The last expression (without ;) is returned automatically.
fn square(x: i32) -> i32 { x * x}fn main() { println!("{}", square(5));}🎯 Exercise & Practice
Test what you've learned — answer, write code, check instantly. (1 left)
🎯 Expected output: 17