Java Closure
Google Neal on Java Closure
几个例子
// before
for(String s : strings) if(something(s)) return calculate(s);
// after
forEach(string, new OneArg<String>() {
public void invoke() {
if(something(s)) return calculate(s); // ERROR, you cannot return or break a loop
}
});
网友评论