Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala+;游戏框架:需要动作组合说明_Scala_Playframework 2.0 - Fatal编程技术网

Scala+;游戏框架:需要动作组合说明

Scala+;游戏框架:需要动作组合说明,scala,playframework-2.0,Scala,Playframework 2.0,这是从Play框架附带的示例中获取的动作合成 def IsAuthenticated(f: => String => Request[AnyContent] => Result) = Security.Authenticated(username, onUnauthorized) { user => Action(request => f(user)(request)) } 因此,Security.Authenticated采用username:

这是从Play框架附带的示例中获取的动作合成

def IsAuthenticated(f: => String => Request[AnyContent] => Result) = Security.Authenticated(username, onUnauthorized) { user =>
    Action(request => f(user)(request))
  }   
因此,
Security.Authenticated
采用
username:RequestHeader=>选项[String]
onauthenticated:RequestHeader=>SimpleResult
第二组paranethes采用
String=>操作[A]

然后在控制器中,我有:

def index = isAuthenticated { ...code }}  
上面的代码就是这个,所以我假设这是
f
函数
=>String=>Request[AnyContent]=>Result
。现在,我不明白这里到底发生了什么。我说的不是
User.findByEmail….
,我说的是
username=>。
。如果我直接调用这个函数,它的签名会是什么样子

username => _ =>
    User.findByEmail(username).map { user =>
      Ok(
        html.dashboard(
          Project.findInvolving(username), 
          Task.findTodoInvolving(username), 
          user
        )
      )
    }.getOrElse(Forbidden)  
如果有
def被验证(f:=>Request[AnyContent]=>Result)
我会知道如何使用它,并且我会理解它。但是额外的“数据”让我困惑

更新:

我想我发现了一些东西:

def f2: String => Int => List[Char] = x => _ => x.toList  
这将被称为:

f2("Andrew")(2) //there can be anything replacing 2 because I don't have access to it anyway  
因此,我主要询问的上述功能是:

def f: => String => Request[AnyContent] => Result = username => _ => User.find.....  
我说得对吗?
我得到一个“此处不允许按名称使用参数”错误


如果他们不使用第二个参数,为什么他们使用
String=>Request=>Result
,而不仅仅是
String=>Result

该函数定义实际上是一个通用函数定义

String=>Request=>Result
实际上意味着:
f(s:String):(r:Request)=>Result
即接受字符串并返回接受请求并返回结果的函数


查看“增加功能”部分:

对我来说,中的示例非常有启发性。

也许有时您需要第二个参数: