1/6

You've been writing code inside main — but a program that's all main is a forge with one giant recipe nailed to the wall.

A function is a recipe you write once and use forever: it takes ingredients, does the work, and hands back a result.

fn double(x: i32) -> i32 {
    x * 2
}