2013-08-30 158 views

回答

7

你不能用匿名函数文字做这个,你需要扩展Function特质。例如。

val f = new (() => Int) { 
    override def toString = "yes" 
    def apply() = 1 
} 

val f = new Function0[Int] { 
    override def toString = "yes" 
    def apply() = 1 
} 
相关问题