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

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

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