使用参数`Unit`设置#application

时间:2015-07-14 15:02:29

标签: scala

Scala Puzzlers提出了这个“益智游戏”:

scala> List("1", "2").toSet() + "3"
warning: there was one deprecation warning; re-run with -deprecation for details
res13: String = false3

该解释说明上述代码消除了:

(List("1", "2").toSet[Any] apply ()) + "3"

但为什么以下内容不会返回false

scala> Set("1")()
<console>:11: error: not enough arguments for method apply: (elem: String)Boolean in trait GenSetLike.
Unspecified value parameter elem.
       Set("1")()
               ^

0 个答案:

没有答案