Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> 3. You can't do closures in Java. You can. It's just incredibly verbose.

It looks like you're confusing closures with lambda expressions. That's an example of (a more verbose functional equivalent of) a lambda expression, but it isn't a closure.

Java's anonymous inner classes can close over variables in enclosing classes, but they can capture only final variables directly from the enclosing lexical scope. So Java actually does not support true closures.



While I agree about the parent confusing closures and anonymous functions, it is possible to use anonymous inner classes as such if the final variable is a single-element array.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: