Olha o que vai ter no java 1.7
Divertido :)
Fonte:
http://guj.com.br/posts/list/99477.java
public class A {
public static void main(String args[]) {
exec( { int a, int b => a + b });
exec( { int a, int b => a * b });
exec( { int a, int b =>
System.out.println("closure " + a + ":" + b);
(a * a) + (b * b)
});
}
public static void exec({ int, int => int } closure){
System.out.println(closure.invoke(3,2));
}
}
$ java -Xbootclasspath/p:./closures-2008-08-04/lib/closures.jar A
5
6
closure 3:2
13
Divertido :)
Fonte:
http://guj.com.br/posts/list/99477.java
Imagina uma classe fazendo um TRAP… hehehe!
[]’s
Cacilhas, La Batalema