Normally I would do:
Function<Integer, Integer> a = b -> b * 2;
System.out.println(a.apply(3)); // prints 6
I was amazed to see that following EL expression works:
${a = b -> b * 2; a(3)}
The result of above EL expression is 6
. How can compiler determine the type when declaring a
in snippet 2 but requires type information in snippet 1?
Even this compiles and executes fine:
${(b -> b * 2)(3)}