I am new to scala, today I saw a function definition I could not understand:
def f(x: Int): Int = x
val func = (x: Int, y: Int, z: Int) => f(x)
So in Scala, what is the syntax of defining func
? To me, func
is just a function accepts three parameters: func: (Int, Int, Int) => Int = <function3>
. Why not just define func
as
def func(x: Int, y: Int, z: Int): Int = f(x)
Is this for the reason of efficiency ? Since we just need to evaluate a val once.