Last active
January 31, 2016 10:58
-
-
Save erangaeb/c5880e40fb4672cdac59 to your computer and use it in GitHub Desktop.
Scala multiple inheritance via traits
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 Language { | |
| def lang(): Unit | |
| } | |
| trait Functional extends Language { | |
| override def lang() { | |
| println("Functional") | |
| } | |
| } | |
| trait ObjectOriented extends Language { | |
| override def lang() { | |
| println("ObjectOriented") | |
| } | |
| } | |
| class Scala extends Functional with ObjectOriented | |
| new Scala().lang() // output --> ObjectOriented | |
| class Scala extends ObjectOriented with Functional | |
| new Scala().lang() // output --> Functional |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment