Tin

Examples · learn/03-functions · 87 of 339

return

examples/learn/03-functions/return.tintin run examples/learn/03-functions/return.tin
fn describe(n: int): string {
  if n < 0 { return "negative" }    // return leaves the function early
  if n == 0 { return "zero" }
  "positive"
}

fn main() {
  print(describe(-4))
  print(describe(0))
  print(describe(9))
}