final def apply(block: => Result): Action[AnyContent] =
apply(BodyParsers.utils.ignore(AnyContentAsEmpty: AnyContent))(_ => block)
Does Anybody know what does this
AnyContentAsEmpty: AnyContentmean ?
It is a Typed Expression.
This is a Type Ascription, which is used to ascribe a type to an expression, thus making the expression a typed expression.
Normally, Scala computes the types of expressions without your help, but you can ascribe a specific type to an expression, if you don't like the one that Scala computes.
For example, for the expression
Scala computes the type
Int. You could also write
instead, and you would get the same result. If you don't want
42 to be typed as
Int, you can ascribe a different type to it, e.g.:
Now, the expression has type
Long instead of
Int. If you were to assign it to a
val, for example, and don't provide a type for the
val, Scala would infer type
val a = 1 // 1 has type Int, therefore Scala infers type Int for a val b: Long = 1 // b is typed as Long, therefore Scala converts 1 to a Long val c = 1: Long // 1 is typed as Long, therefore Scala infers type Long for c
You can use this to guide Scala to infer a more sensible type, or to pick a particular overload.