トレイトの定義
scala> trait Cat {
| def meow(): String
| }
defined trait Cat
scala> new Cat
<console>:7: error: trait Cat is abstract; cannot be instantiated
new Cat
^
scala> trait FuzzyCat extends Cat {
| override def meow(): String = "Meeeeeeeeeeow"
| }
defined trait FuzzyCat
scala> new FuzzyCat
<console>:8: error: trait FuzzyCat is abstract; cannot be instantiated
new FuzzyCat
^
scala> trait OtherThing {
| def hello() = 4
| }
defined trait OtherThing
scala> new OtherThing
<console>:7: error: trait OtherThing is abstract; cannot be instantiated
new OtherThing
^
scala> class Yep extends FuzzyCat with OtherThing {
| }
defined class Yep
scala> new Yep
res3: Yep = Yep@820d53
scala> (new Yep).hello
res4: Int = 4
scala> (new Yep).hello()
res5: Int = 4