Tin

Examples · learn/10-generics · 164 of 339

task-2.solution

examples/learn/10-generics/task-2.solution.tintin run examples/learn/10-generics/task-2.solution.tin
type Box<T> = { label: string, item: T }

fn Box.open<T>(b: Box<T>): T => b.item

fn main() {
  let a = Box { label: "number", item: 42 }
  let b = Box { label: "word", item: "tin" }
  print("{a.label}: {a.open()}")
  print("{b.label}: {b.open()}")
}