How to define function literal with multiple implicit arguments in Scala? I\'ve tried this way:
def create = authAction { (implicit request, user) ⇒ // Synta
As stated in previous answer, you can only define a single implicit parameter for a function literal, but there is workaround.
Instead of multiple implicit arguments you can write function literal as taking multiple argument lists with one argument each. Then it is possible to mark each argument as implicit. Rewriting original snippet:
def create = authAction { implicit request ⇒ implicit user ⇒
Ok(html.user.create(registrationForm))
}
You can call it from authAction
as f(request)(user)
.
implicit
keyword duplication is annoying, but at least it works.