Advertisement
|
The closures are coming!
The closures are coming!!
The closures are coming!!!
And don't let your baby cry out loud.
To celebrate Java's entry into the closures era, today's Java quiz is about closures, specifically the BGGA closures.
Will the following
public class Fib {
private static {int=>int} fib = {
int n =>
n==0 ? 0 :
n==1 ? 1 :
fib.invoke(n-1) + fib.invoke(n-2)
};
public static void main(String[] args) {
System.out.println(fib.invoke(6));
}
}
program compile? Run? If so, what will it print out?
You can bend the rules and actually run the prototype compiler that is available here.
Read: Friday Java Quiz: Know Your Closures