Tin

Examples · learn/09-closures · 148 of 339

closure

examples/learn/09-closures/closure.tintin run examples/learn/09-closures/closure.tin
fn main() {
  // (x) => ... is a function without a name: a closure
  let inc = (x: int) => x + 1
  print(inc(41))

  let bonus = 10
  let addBonus = (score: int) => score + bonus   // it can use names from around it
  print(addBonus(80))
}