I have this piece of Scala code:
trait A {
def message(): Unit = println("I am A")
}
trait B extends A {
override def message(): Unit = {
println("I am B")
}
}
trait C extends A {
override def message(): Unit = {
println("I am C")
}
}
trait D extends C {
override def message(): Unit = {
println("I am D")
}
}
object Main extends App {
(new D with A with C with B).message
(new A with D with C with B).message
(new A with C with D with B).message
}
The output is I am B
in all three println
. Could you please help me to explain why the input is the same? Thank you in advance!