Created
May 13, 2012 13:53
-
-
Save komamitsu/2688571 to your computer and use it in GitHub Desktop.
Trait as Stackable modifications
This file contains 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
// Either is OK. | |
// abstract Base { def say(word: String) } | |
trait Base { def say(word: String) } | |
class Hoge extends Base { def say(word: String) = println(word) } | |
trait Smile extends Base { abstract override def say(word: String) = super.say(word + " :)") } | |
trait Hello extends Base { abstract override def say(word: String) = super.say("Hello " + word) } | |
object Hoge extends App { | |
val hoge = new Hoge with Smile with Hello | |
hoge.say("World") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$ scalac Hoge.scala
$ scala Hoge
Hello World :)