Tin

Examples · learn/11-values · 170 of 339

copy-struct

examples/learn/11-values/copy-struct.tintin run examples/learn/11-values/copy-struct.tin
type Robot = { name: string, battery: int }

fn main() {
  var first = Robot { name: "Bud", battery: 90 }
  var second = first           // a copy, not a second name for the same robot
  second.name = "Petal"
  second.battery = 40
  print(first)
  print(second)
}