Skip to content

Instantly share code, notes, and snippets.

@pawelpanasewicz
Last active August 29, 2015 14:07
Show Gist options
  • Save pawelpanasewicz/f4185e5c1a18b4a5b147 to your computer and use it in GitHub Desktop.
Save pawelpanasewicz/f4185e5c1a18b4a5b147 to your computer and use it in GitHub Desktop.
stackable modifications
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