I think this is a newbie question but why it fails on the last assertion? I was thinking that the closure binds the value on it, so changing it from the closure will change the value outside the closure.
def value = 5
def foo(n){
return {
++n
}
}
def test = foo(value)
assert test() == 6
assert test() == 7
assert value == 7
Thanks for help.