A self-type for a trait A
:
trait B
trait A { this: B => }
says that \"A
cannot be mixed into a concrete cl
TL;DR summary of the other answers:
Types you extend are exposed to inherited types, but self-types are not
eg: class Cow { this: FourStomachs }
allows you to use methods only available to ruminants, such as digestGrass
. Traits that extend Cow however will have no such privileges. On the other hand, class Cow extends FourStomachs
will expose digestGrass
to anyone who extends Cow
.
self-types allow cyclical dependencies, extending other types does not