Last active
August 29, 2015 14:07
-
-
Save pawelpanasewicz/f4185e5c1a18b4a5b147 to your computer and use it in GitHub Desktop.
stackable modifications
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
trait Animal{ | |
println ("creating Animal") | |
def speak: String | |
} | |
trait PrettyAnimal extends Animal{ | |
println ("creating Pretty Animal") | |
abstract override def speak = s"Pretty(${super.speak})" | |
} | |
trait Cow extends Animal { | |
println ("creating Cow") | |
override def speak: String = "moo" | |
} | |
object animals { | |
val cow = new Cow{} | |
cow.speak | |
val prettyCow = new Cow with PrettyAnimal | |
prettyCow.speak | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment