Created
March 14, 2013 14:17
-
-
Save tyrcho/5161680 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
abstract class Animal { | |
def greetings { | |
println("an animal") | |
} | |
} | |
trait Mammal extends Animal { | |
abstract override def greetings { | |
println("I'm a mammal") | |
super.greetings | |
} | |
} | |
trait Carnivore extends Mammal { | |
abstract override def greetings { | |
println("I'm a carnivore") | |
super.greetings | |
} | |
} | |
trait FourLegged extends Animal { | |
abstract override def greetings { | |
println("I have four legs") | |
super.greetings | |
} | |
} | |
object Dog extends Carnivore with FourLegged { | |
override def greetings { | |
println("I'm a dog") | |
super.greetings | |
} | |
} | |
Dog.greetings |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment