1
IM試圖理解Scala中的下面的高階函數,但需要對函數的參數進行一些說明。Scala中的高階函數
問題: -
- 是什麼在
apply
功能Int => String
是什麼意思?v: Int
表示參數v的類型爲Int
。 [A](x: A)
是什麼意思layout
函數?object Demo { def main(args: Array[String]) { println(apply(layout, 10)) } def apply(f: Int => String, v: Int) = f(v) def layout[A](x: A) = "[" + x.toString() + "]" }