scala中匿名函数
Scala中的匿名函数 (Anonymous functions in Scala)
A function with no name is an anonymous function which is also known as function literal. This type of functions is used when the user wants to create an inline function.
没有名称的函数是匿名函数,也称为函数文字 。 当用户想要创建内联函数时,使用这种类型的函数。
Syntax:
句法:
1) (x: Int , y:Int) => x + y
2) (_:Int) + (_:Int)
Syntax explanation:
语法说明:
There are two syntaxes to define an anonymous function in Scala. First one uses a transformer ( => ) to the anonymous function. The second code directly uses a wildcard (