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" }

List(Cat("Molly", 9), Dog("Fenton", 6))
  .retain(|p| > 5)
  .map   (|p| describe(p))
  .each  (|d| println(d))
// → dog Fenton is 6 years of age