By-name parameters

SQLContext.scala

protected def stringOrError[A](f: => A): String =
      try f.toString catch { case e: Throwable => e.toString }

参见 http://www.scala-lang.org/files/archive/spec/2.11/04-basic-declarations-and-definitions.html 4.6.2 This indicates that the corresponding argument is not evaluated at the point of function application, but instead is evaluated at each use within the function. That is, the argument is evaluated using call-by-name. 用的时候才会计算参数

应该是f: ()=>A的省略

results matching ""

    No results matching ""