我有一個Trait及其實現,其中我想以簡明的方式重用現有函數。這裏是例子:在Scala中實現特徵的部分功能
object Util {
def foo(a: Int, b:Int): Int = {// some implementation}
}
trait Animal {
def eat(a: Int, b: Int): Int
}
object Dog extends Animal {
import Util._
def eat(a: Int, b:Int): Int = foo(a, b)
/* Is this any concise way for the above?
* For example, I am looking for something
* like this to work:
*/
// def eat = foo
// def eat = foo(_, _)
// val eat = foo(_, _)
}