When two traits are defined like this,
trait A
trait B extends A
what is the difference between these two.
class C extends B
class D extends A with B
I do not think it is necessary for class C or D to extends trait A since trait B already extends trait A.
Why is this often written "class D extends A with B" ?
It's a pretty good question... I'll try to answer with a subjective response.
I guess that extends A
mixin with B
is important when the hierarchy will be linearized, in this particular case there is no differences but what if you mixin D
with another trait E
that reimplements some (but not all) functions from A which aren't well advised in B
for your needs in D
. So you'd have
class D extends A with E with B
Moreover in that case, we keep the meaning that D
is a A
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With