Zelong
Zelong

Reputation: 2556

Anonymous function as argument in scala

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]?

Upvotes: 3

Views: 303

Answers (2)

Guenter Guckelsberger
Guenter Guckelsberger

Reputation: 940

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.

Upvotes: 0

Related Questions