Is it possible to specify an anonymous function's return type, in Scala?

Geo picture Geo · Jan 18, 2010 · Viewed 13.5k times · Source

I know you can create an anonymous function, and have the compiler infer its return type:

val x = () => { System.currentTimeMillis }

Just for static typing's sake, is it possible to specify its return type as well? I think it would make things a lot clearer.

Answer

Fabian Steeg picture Fabian Steeg · Jan 18, 2010
val x = () => { System.currentTimeMillis } : Long