RosettaCodeData/Task/Constrained-genericity/Scala/constrained-genericity.scala
2023-07-01 13:44:08 -04:00

11 lines
201 B
Scala

type Eatable = { def eat: Unit }
class FoodBox(coll: List[Eatable])
case class Fish(name: String) {
def eat {
println("Eating "+name)
}
}
val foodBox = new FoodBox(List(new Fish("salmon")))