Tin

Examples · learn/03-functions · 82 of 339

define

fn name(parameter: type, ...): result type { body }

examples/learn/03-functions/define.tintin run examples/learn/03-functions/define.tin
// fn name(parameter: type, ...): result type { body }
fn add(a: int, b: int): int {
  a + b                    // the last expression is the result
}

fn main() {
  print(add(2, 3))
  let total = add(add(1, 2), 10)
  print(total)
}