简体   繁体   English

匿名函数作为Scala中的参数

[英]Anonymous function as argument in scala

In Play 2.3, the Action.async method has the signature 在Play 2.3中, Action.async方法具有签名

final def async(block: ⇒ Future[Result]): Action[AnyContent]

I did not figure out the meaning of => Future[Result] , is it an anonymous function? 我没有弄清楚=> Future[Result]的含义,这是一个匿名函数吗? Then shouldn't it be () => Future[Result] ? 那不是() => Future[Result]吗?

This is a call by name not by value as usual. 这是一个按名称的呼叫,而不是通常的按值的呼叫。 It means, the argument, here block is of Type Future[Result] and it is lazy evaluated when needed not instantly on function call. 这意味着,这里的参数块的类型为Future [Result],并且在不需要立即调用函数时被懒惰地求值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM