Problem with lambda expression

Howard Lovatt howard.lovatt at gmail.com
Sat Aug 21 21:58:14 PDT 2010


For the extension method:

  <throws E> extension void forEach( Method1<T, T, E> method ) throws
E default Trait.forEach;

Called with:

    il.forEach( #( i ) { 2 * i } ); // No exception, no try block

Gives:

lambdas/Main.java:30: integer number too large: i
    il.forEach( #( i ) { 2 * i } ); // No exception, no try block
                         ^
(The arrow points to the 2 in a mon-spaced font.) Whereas:

    il.forEach( #( i ) { return 2 * i; } ); // No exception, no try block

Works as expected.

  -- Howard.


More information about the lambda-dev mailing list