JEP draft: Concise Method Bodies - extend this to local functions?
alex.buckley at oracle.com
Thu Sep 20 20:46:51 UTC 2018
On 9/20/2018 1:28 PM, Maurizio Cimadamore wrote:
>>> Function<A,B> fun() = Utils::bar;
>>> Function<A,B> fun = Utils::bar;
>>> (first is method body, second is variable initializer)
>> I think Remi is noting the fact that, when using `->`, the single
>> expression can be a method reference expression. I have already
>> recorded this situation near the end of the JEP.
> Ok - then I added another :-) [not sure we should be worried about it,
> but perhaps worth mentioning in the JEP]
The puzzler practically writes itself. We distinguish:
1. boolean isEmpty(String s) = String::isEmpty;
2. Predicate<String> isEmpty = String::isEmpty;
3. Predicate<String> isEmpty(String s) -> String::isEmpty;
1. Method declaration, using method reference form.
2. Field declaration, initialized with a method reference exprssion.
3. Method declaration, using single expression form.
More information about the amber-spec-experts