fork download
  1. class Animal() {
  2. def says():String = "???"
  3. }
  4. class Dog() extends Animal {
  5. override def says():String = "woof"
  6. }
  7.  
  8. class Zoo[A <: Animal](thing: A) {
  9. def whoami()=thing.getClass
  10. def chat()=thing.says
  11. }
  12.  
  13.  
  14. object Main extends App {
  15.  
  16.  
  17. val adog = new Dog
  18. val cage = new Zoo[Dog](adog)
  19.  
  20. println(cage.chat())
  21.  
  22. }
Success #stdin #stdout 0.37s 382080KB
stdin
Standard input is empty
stdout
woof