I'm playing with future java 8 release aka JDK 1.8.
And I found out that you can easily do
interface Foo { int method(); }
and use it like
Foo foo = () -> 3;
System.out.println("foo.method(); = " + foo.method());
which simply prints 3.
And I also found that there is a java.util.function.Function interface which does this in a more generic fashion. However this code won't compile
Function times3 = (Integer triple) -> 3 * triple;
Integer twelve = times3.map(4);
And it seems that I first have to do something like
interface IntIntFunction extends Function<Integer, Integer> {}
IntIntFunction times3 = (Integer triple) -> 3 * triple;
Integer twelve = times3.map(4);
So I'm wondering if there is another way to avoid the IntIntFunction step?