Scala method call parameters with colon -


final def apply(block: => result): action[anycontent] =     apply(bodyparsers.utils.ignore(anycontentasempty: anycontent))(_ => block) 

does know anycontentasempty: anycontent mean ? particularly : anycontent ?

does know anycontentasempty: anycontent mean ?

it typed expression.

particularly : anycontent ?

this type ascription, used ascribe type expression, making expression typed expression.

normally, scala computes types of expressions without help, can ascribe specific type expression, if don't 1 scala computes.

for example, expression

42 

scala computes type int. write

42: int 

instead, , same result. if don't want 42 typed int, can ascribe different type it, e.g.:

42: long 

now, expression has type long instead of int. if assign val, example, , don't provide type val, scala infer type long:

val       = 1       // 1 has type int, therefore scala infers type int val b: long = 1       // b typed long, therefore scala converts 1 long val c       = 1: long // 1 typed long, therefore scala infers type long c 

you can use guide scala infer more sensible type, or pick particular overload.


Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -