以下代码不起作用: FileSystems.getDefault.getPath来自java.nio包
更新
方法createCalculation是:
注意:MyLocation是一个扩展MyMessage的案例类
def creatCalculation(myPlace: MyLocation): MyMessage = {
if (some test) {
//--- some code
} else
MyError("My Calculation already done")
MyAck //returning the case object MyAck which is of type MyMessage
}
// Req是来自:net.liftweb.http.Req
的类val someVal: PartialFunction[Req, () => Box[LiftResponse]] {
case "create" :: Nil JsonPostAndApproval s =>
postResponse(s, (j: JValue, p: Permissions, r: Req) => {
createCalculation(fromJValue[MyLocation](j) = {
case "MyAck" => {
val myCalculator: Calculator = new Calculator(FileSystems.getDefault.getPath(fromJsonVal[MyLocation](s._1).path))
val resultsMap = myCalculator.foreach( (p) => Map[String, Int])
for( (myKey, myValue) <- resultsMap) {
printf("key: %s, value: %s\n", myKey, myValue)
}
}
})
} ) ("Failed to calculate")
}
编译器抱怨如下:
[error] C:\Users\lulu\ExampleHandler.scala:129: missing arguments for
method fromJValue in package json;
[error] follow this method with `_' if you want to treat it as a partially applied function
[error] createCalculation(fromJsonVal[MyLocation](j) = {
[error] ^
这是fromJsonVal
的方法定义/**
* Routine to convert JValue to native type
*
* @param in JValue to convert
* @tparam T native type to extract
* @return extracted native type
*/
def fromJsonVal[T: Manifest](in: JValue): T = in.extract[T]
JValue来自net.liftweb / json并且是: 密封的抽象类JValue()使用net.liftweb.json.Diff.Diffable扩展java.lang.Object { &LT;&GT; }
更新:编译器在此代码行中报告错误
您认为我应该如何更正此编译错误?
createCalculation(fromJValue[MyLocation](j) = {
答案 0 :(得分:0)
如果没有完整的图片,我认为错误仅仅来自于您尝试将输出分配给方法和丢失的parens。没有完整的图片,我的猜测是你正在寻找更像的东西:
createCalculation(fromJValue[MyLocation](j)) match {
case "MyAck"....
请注意j