every function in scala is an instance of a class
程序员文章站
2024-01-07 20:48:58
...
Created by Wang, Jerry, last modified on Jan 11, 2016
object MainFunction0Test extends App {
val suc = (x:Int)=> x + 1
val sud = new Function1[Int, Int] {
def apply(x:Int): Int = x + 1
}
assert(suc(0) == sud(0))
}
myInt即为形参。
another way:
Since in Scala you can use type inference you don’t have to declare the type so the following would be equivalent:
要获取更多Jerry的原创文章,请关注公众号"汪子熙":