【发布时间】:2014-09-06 06:09:56
【问题描述】:
我不明白为什么这不起作用:
case class Expression extends Node[Doube] {
def apply(implicit symbolTable: Map[String,Double]) = value
}
请注意,值是在 Node 中定义的,也带有隐式符号表参数。
当我尝试像这样调用它时:
implicit val symbolTable = Map("a"->1, "b"->2)
//and x is an Expression, then:
x() // does not compile (can't find implicit) but
x(symbolTable) // works fine
奇怪的是:
x.value // works fine too
如果我这样写申请:
def apply()(implicit symbolTable: Map[String,Double])
它有效,但我不明白为什么我需要这样做......
任何指针?
【问题讨论】: