RosettaCodeData/Task/Constrained-genericity/Scala/constrained-genericity.scala

12 lines
201 B
Scala
Raw Permalink Normal View History

2013-04-10 16:57:12 -07:00
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")))