这不起作用:
"%-10s %-50s %s".format _
<console>:13: error: missing arguments for method format in trait StringLike;
follow this method with `_' if you want to treat it as a partially applied function
"%-10s %-50s %s".format _
但这有效:
import scala.collection.immutable._
scala> ("%-10s %-50s %s": StringLike[_]).format _
res91: Seq[Any] => String = <function1>
那么,为什么我必须明确指定类型类?
答案 0 :(得分:1)
这就是原因:
https://issues.scala-lang.org/browse/SI-8299
这不是一个原因。
不确定是否需要说,但是:
scala> val f: Seq[Any] => String = "%-10s %-50s %s".format
f: Seq[Any] => String = <function1>