【发布时间】:2009-08-05 13:29:18
【问题描述】:
我正在阅读这本精彩的书Programming in Scala,这时我遇到了一段对我来说毫无意义的代码:
def above(that: Element): Element = {
val this1 = this widen that.width
val that1 = that widen this.width
elem(this1.contents ++ that1.contents)
}
注意第 2 行和第 3 行:
val this1 = this widen that.width
看来我应该可以将其替换为:
val this1 = this.widen that.width
但是,当我尝试编译此更改时,会出现以下错误:
错误:';'预期但“。”成立。
val this1 = this.widen that.width ^
为什么这种语法不可接受?
【问题讨论】: