Lambda conversion in Method invocation context

Maurizio Cimadamore maurizio.cimadamore at oracle.com
Fri Nov 12 06:08:44 PST 2010


On 12/11/10 13:28, Peter Levart wrote:
>>> I think, you're trying to write this:
>>>
>>> executor.submit(
>>>     #{ System.out.println("Processing a short-lived asynchronous task."); }
>>> );
>>>
>>> ...note the semicolon after println method invocation. Invocation of a void method can not be used as expression.
>>>
>>>        
> On 11/12/10, Maurizio Cimadamore wrote:
>    
>> The semi-colon should not represent a problem.
>>      
> Oh, so this is valid code?
>
> Runnable r = #{  System.out.println() };
>    
Yes it is. A method invocation is also an expression so it is possible 
to exploit the lambda expression syntax (w/o semicolon).

Maurizio
>
> Peter
>    



More information about the lambda-dev mailing list