Examples · learn/10-generics · 164 of 339
task-2.solution
tin run examples/learn/10-generics/task-2.solution.tintype 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()}")
}