Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 1.0-JSR-2
-
Fix Version/s: 1.0-JSR-5
-
Component/s: class generator
-
Labels:None
-
Environment:HEAD
-
Testcase included:yes
Description
You cannot set variables more than one closure aware from their scope:
def t = 2;
[1].each {
[1].each {
t = 1;
}
}
println t;
This currently prints 0.
Issue Links
- duplicates
-
GROOVY-534
Nested closures - variable scope problem
-
- is depended upon by
-
GROOVY-754
scoping
-
-
GROOVY-764
closures
-
It's really bad, here is another example:
def t = 2;
[1].each {
[1].each {println t; t = 1; }
println t;
}
println t;
This prints 2,2,2.