4 ms·
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
by BDFL_Xenu 15y 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?
- spullara 15y agoThe single abstract method interface type of a lambda will be inferred by its declaration site.
- umjames 15y agoWill they be full closures and remember the state of objects in scope?
- BDFL_Xenu 15y agoIf 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).
- spullara 15y agoThey 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.