功能字面含多个隐参数 [英] Function literal with multiple implicit arguments

查看:120
本文介绍了功能字面含多个隐参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何定义函数文本在斯卡拉多个隐参数呢?我试过这样:

How to define function literal with multiple implicit arguments in Scala? I've tried this way:

def create = authAction { (implicit request, user) ⇒ // Syntax error
  Ok(html.user.create(registrationForm))
}

但它抛出编译错误。

but it throws compilation error.

推荐答案

从我能理解的语言规范,截至版本2.9.2只能定义一个隐含参数为匿名函数。

From what I can understand of the language specification, as of version 2.9.2 you can only define a single implicit parameter for anonymous functions.

例如

val autoappend = {implicit text:String => text ++ text}

这篇关于功能字面含多个隐参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆