我还不熟悉Scala语言,发现了Spray框架中的这段代码。
我试图了解这个方法签名的含义:
/**
* Completes the request using the given arguments.
*/
def complete: (⇒ ToResponseMarshallable) ⇒ StandardRoute = marshallable ⇒ new StandardRoute {
def apply(ctx: RequestContext): Unit = ctx.complete(marshallable)
}
这里的
=>
运算符是用来做什么的?我原以为它是用来创建闭包的?
这里对marshallable进行了赋值操作,为什么要在括号外面赋值?希望能看到这段代码的Java版本。