我努力理解const sum = num => {
return Array.from(
Array(num).keys(),
key => key + 1
).reduce(
(v1, v2) => v1 + v2
)
}
,因此想到重构一段代码以使其更加合理。但是我无法这样做。
原始代码是
Scala
我想对代码进行解糖处理,并使调用更加明确。我在考虑以下行中的内容
def index(signupMessage:String = "") = addToken { //addToken is of CSRFAddToken
silhouette.UserAwareAction { implicit request =>
println(s"index action called with request ${utilities.printPlayHttpRequest(request)}")
//TODOM - fix as signup value is coming up as ;signup=error or ;signup=success instead of just success or error
println(s"index page's argument "+signupMessage)
val Token(name, value) = CSRF.getToken.get
println(s"Token name ${name}, value ${value}")
Ok(views.html.index(signupMessage,messagesApi("app.title")(langs.availables(0))))
}
}
上面的代码无法编译。我在做什么错了?
答案 0 :(得分:1)
我认为您需要这样写Action
:
val block = Action { implicit request =>
// Rest of code here
}