=>(scala)
1Function<n>[A[,B,...],T] :a function that takes parameters of type A[,B...], and returns a value of type T.
2=>() :A function that returns Unit is also known as a procedure, normally a method that's called only for its side effect.
3f(param: => T) :it's a "by-name parameter", meaning that is evaluated every time it's used within the body of the function, and not before. Ordinary "by-value" parameters are evaluated before entry into the function/method.
=> is syntactic sugar for creating instances of functions. Recall that every function in scala is an instance of a class.
val f: Function1[Int,String] = myInt => "my int: "+myInt.toString
val f2: Int => String = myInt => "my int v2: "+myInt.toString
f: (Int) => String = <function1>
浙公网安备 33010602011771号