class Cat(let name: String, let lives: Int64)
class Dog(let name: String, let years: Int64)
union Pet of Cat, Dog

fun describe(pet: Pet): String = if pet
  ... is Cat(let name, let lives) { "cat $name has $lives lives" }
  ... is Dog(let name, let years) { "dog $name is $years of age" }

describe(Cat("Molly", 9))
// → cat Molly has 9 lives