标签:instance eating func tac code expr lua effect exp
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.
5case x => y :separate the pattern (and optional guard) from the result expression
=>
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>
标签:instance eating func tac code expr lua effect exp
原文地址:http://www.cnblogs.com/yumanman/p/7559085.html