4 ms·
I come exactly from this background at school, so I never had this 'problem' with Java. It was pretty new to me and kinda not sensed the concept behind closure
by christian_fei 13y ago
I come exactly from this background at school, so I never had this 'problem' with Java.
It was pretty new to me and kinda not sensed the concept behind closures.
I would like to know what you think about the explanation I provided in the post about closures. Did I get the point? Don't hesitate to tell me if I'm totally wrong
- RyanZAG 13y agoYes, spot on. For your original code example, the Java compiler would have failed with an error that the variable 'i' was not declared final (immutable). Java 8 supports lambdas now, but in earlier Java versions you would have had to add a line like 'final int fi = i;' and you could then have used the fi inside the closure. The point in my previous post that the compiler detecting this ambiguity is exceptionally helpful and I'd prefer more languages to follow that route. With Java 8 lambdas, it's much the same but with some nice syntax to make it easier[1]. [1] http://java.amitph.com/2012/08/at-first-sight-with-closures-in-java.html http://java.amitph.com/2012/08/at-first-sight-with-closures-...
- christian_fei 13y agonever got that much into Java though