Skip to content

Instantly share code, notes, and snippets.

@rupeshtr78
Created November 1, 2020 19:41
Show Gist options
  • Save rupeshtr78/b744554d1c67a2f426e1c2b4fa0df273 to your computer and use it in GitHub Desktop.
Save rupeshtr78/b744554d1c67a2f426e1c2b4fa0df273 to your computer and use it in GitHub Desktop.
trait A {
def hello():String = "Trait A"
}
trait B extends A {
override def hello(): String = "Trait B ->" + super.hello()
}
trait C extends A {
override def hello(): String = "Trait C->" + super.hello()
}
class D extends A {
override def hello(): String = "Class D ->" + super.hello()
}
object Diamond extends D with B with C {
override def hello(): String = "Diamond ->" + super.hello()
}
Diamond.hello() //Diamond ->Trait C->Trait B ->Class D ->Trait A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment