【发布时间】:2016-01-09 04:07:14
【问题描述】:
使用Spark,我最终得到了如下代码:
post("/auth/login", { req, res ->
val body = parseBody(req.body())
val assertion = body["assertion"]
if (assertion == null) {
halt(400)
return null
}
// ...snip...lots more code
})
这很好用,除了...它不能编译——我得到'return' is not allowed here。
我可以将 lambda 的其余部分放在 else 块中,但我不希望最小化缩进。
那么我如何“短路” lambda 以返回 null?
【问题讨论】:
标签: kotlin spark-java