scala> val service2 = new ServiceImportante("dos") with StdoutLogging { | override def work(i: Int): Int = { | info(s"Starting work: i = $i") | val result = super.work(i) | info(s"Ending work: i = $i, result = $result") | result | } | } service2: ServiceImportante with StdoutLogging = $anon$1@674fee6d
当然也可以重复使用ServiceImportante with StdoutLogging,定义一个新的class