Suppose we have this function definition and invocation:
def sayHello(prefix:String):(String => String) = {
n => s"$prefix $n"
}
val greeting = sayHello("Hello")
greeting("Gio")
Using Intellij, I see the variable "n" inside function is of type String.
Why a variable not declared before is inferred by Scala as String?
I understand this higher order function returns a function String => String
, but I can't see relationship between these two concepts.
Could you provide me a clarification about it?