no closures in java 8 actually
Jan. 2nd, 2013 10:47 amhttps://groups.google.com/forum/?fromgroups=#!topic/scala-user/nC263xUiaQo
The same dumb stupid Java where you can only pass a final into an internal class...
"
The compiler error is: "value used in lambda expression should be effectively final". I got some bad suspicion and tried whether this compiles:
This did compile.
"
The same dumb stupid Java where you can only pass a final into an internal class...
"
List<Integer> ints = new ArrayList<>(); ints.add(1); ints.add(2); ints.add(3); int sum = 0; ints.forEach(i -> {sum += i;});
The compiler error is: "value used in lambda expression should be effectively final". I got some bad suspicion and tried whether this compiles:
int sumArray[] = new int[] { 0 }; ints.forEach(i -> {sumArray[0] += i;});
This did compile.
"