Hacker News new | ask | show | jobs
by BDFL_Xenu 5392 days ago
I see that the proposed lambda expressions can omit type annotations on the parameters. Does that mean that Java 8 will have at least some limited form of type inference?
1 comments

The single abstract method interface type of a lambda will be inferred by its declaration site.
Will they be full closures and remember the state of objects in scope?
If they will be based on anonymous inner classes, then yes, they'll capture the variables from the surrounding scope. Those variables however will be 'final', which means that you can't re-assign them, even if their values are still liable to side-effects (e.g. setting fields, mutating collections, etc).
They are not based on anonymous inner classes (the implementation is likely to be much different) but they have the same restrictions as BDFFL_Xenu described.