Implementing recursive lambda with MethodHandle

Joshua Bloch jjb at google.com
Mon Feb 22 11:28:21 PST 2010


Rémi,

On Mon, Feb 22, 2010 at 10:50 AM, Rémi Forax <forax at univ-mlv.fr> wrote:

>
> This one doesn't clutter up the enclosing scope too :)
>
> #(int i) {
>     return new Object() {
>       int sum(int x) {
>         return (x==0)?0:x + sum(x-1);
>       }
>     }.sum(x);
> };
>
>
Yes, but it uses an (ugly) anonymous class initialization expression.  The
whole idea of this JSR is to eliminate the need for these beasts.

           Josh


More information about the lambda-dev mailing list