Method references with types [Re: lambda syntax tutorial]

Brian Goetz brian.goetz at oracle.com
Fri Aug 6 20:13:55 PDT 2010


You can have arbitrary expressions: to get what you want, just insert some braces:

#{ s -> s.length() + 2 }


On Aug 6, 2010, at 10:36 PM, John Nilsson wrote:

> On Fri, Aug 6, 2010 at 4:30 AM, Brian Goetz <brian.goetz at oracle.com> wrote:
>> For completeness:
>> 
>>>> How about expressions?
>>>> 
>>>> #String.length() + 2
>> 
>> Type error.
>> 
>>>> #A.getB().getC()
>> 
>> Greedy.  Evaluate t=A.getB(), then evaluate to #t.getC().
> 
> If this is greedy, shouldn't the above example also be greedy? I.e.
> t=String.length(), then t+2
> 
> I was kind of hoping for arbitrary expressions. So that it would
> rather be intepreted as #(String s){s.length()+2}
> 
> BR,
> John



More information about the lambda-dev mailing list