20100708

Java closures get type inference, hooray!

According to the latest State of the Lambda document closures in Java will get type inference.

The return type and exception types of a lambda expression are inferred by the compiler; the parameter types may be explicitly specified or they may be inferred from the assignment context.

So this expression will be valid without explicit type annotation:
CallbackHandler cb = { c -> System.out.println("pippo") };
Finally, they seem to have mercy with the humble Java developer.

3 comments: