When learning Scala, I get an example for HIGHER-ORDER FUNCTIONS, from here
https://docs.scala-lang.org/tour/higher-order-functions.html
def apply(f : Int => String, v : Int) = f(v)
def layout[A](x : A) : String = x.toString
println(apply(layout, 1000))
My question is if layout has more than 1 parameters, like this :
def layout[A](x : A, y : A) : String = x.toString + y.toString
for Intuitive understanding, I define apply as follows
def apply(f : Int, Int => String, v : Int, w : Int) = f(v, w)
Of course, this is can not compiled. I think I have a deviation from the understanding of the type of function in Scala.
How to solve this problem with the right posture, and Solve this problem with the right posture, and more in-depth understanding of the definition of scala function types is good.
f: (Int, Int) => String
– Dima