欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

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))
}

every function in scala is an instance of a class
every function in scala is an instance of a class

myInt即为形参。
another way:

every function in scala is an instance of a class

Since in Scala you can use type inference you don’t have to declare the type so the following would be equivalent:

every function in scala is an instance of a class

要获取更多Jerry的原创文章,请关注公众号"汪子熙":
every function in scala is an instance of a class

上一篇:

下一篇: