1 2 3 4 5 6 7 8 9 10 11 12 13
class Foo { def foo = { abstract sealed class Animal case class Goat(age: Int) extends Animal case class Horse(age: Int) extends Animal val x: Animal = Goat(1) x match { case Goat(_) => println("a goat") } } }