【发布时间】:2012-08-13 17:55:13
【问题描述】:
可能重复:
Scala underscore - ERROR: missing parameter type for expanded function
假设以下代码编译(people 是List[Person]):
people.map(_.address).foreach(println)
为什么会这样:
people.foreach(println(_.address))
生成消息
missing parameter type for expanded function ((x$4) => x$4.address)
这似乎是任何时候通配符嵌套在方法调用中的情况。
这是因为编译器试图将代码扩展为吗?:
people.foreach(println(x => x.address))
【问题讨论】:
标签: scala