2

In Play 2.3, the Action.async method has the signature

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

I did not figure out the meaning of => Future[Result], is it an anonymous function? Then shouldn't it be () => Future[Result]?

Zelong
  • 2,476
  • 7
  • 31
  • 51
  • 1
    You can find your answer here: http://stackoverflow.com/questions/22670356/scala-passing-function-as-block-of-code-between-curly-braces and in many other similar questions. – Łukasz Dec 17 '15 at 09:14

2 Answers2

2

It is a "By-name parameter":

Community
  • 1
  • 1
Filippo Vitale
  • 7,597
  • 3
  • 58
  • 64
0

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.