问题
I wrote a function which returns a function based on the String argument it receives. The code looks as follow:
def getFunction(str:String) : Map[String, String] => String={
val s = str.charAt(0).toString()
s matches {
case "x" => (arg:Map[String, String]) => arg("random")
case _ =>(arg:Map[String, String]) => arg("")
}
}
This is giving a compilation exception
Description Resource Path Location Type
missing parameter type for expanded function The argument types of an anonymous function must be fully known. (SLS 8.5) Expected type was: String line 9 Scala Problem.
I looked into: The argument types of an anonymous function must be fully known. (SLS 8.5).
But could understand the solution. Can anyone explain what is wrong with above code.
Thanks
来源:https://stackoverflow.com/questions/39345561/scala-type-missing-parameter-type-for-expanded-function-the-argument-types-of-a