Key to understanding here are the following:
- Scala
traits , . . - , class
trait.
trait , AnyRef.
, - :
class Foo \\ 1
trait FooTrait extends Foo \\ 2
class Bar extends FooTrait \\ 3
.
val bar = new Bar with FooTrait
.
, Bar. . val bar = new Bar, Bar Bar. Bar.
, , - val bar = new Bar with FooTrait, . :
JVM , , . . :
trait Foo
trait FooTrait extends Foo
class Bar
val pass = new Bar with FooTrait
, Java.