Skip to content

Instantly share code, notes, and snippets.

@erangaeb
Last active January 31, 2016 10:58
Show Gist options
  • Save erangaeb/c5880e40fb4672cdac59 to your computer and use it in GitHub Desktop.
Save erangaeb/c5880e40fb4672cdac59 to your computer and use it in GitHub Desktop.
Scala multiple inheritance via traits
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