Using Groovy closures to fake Python generators

Here is a quick example of faking python generators with Groovy. Please update the comments if you have a better approach.

def (a,b,sent,acc) = [0,1,null,0]
def fib={
    (a,b) = [b,a+=b]
    a
}

while(true){
    currFibValue = fib()
    if( currFibValue > 4000000) break
    else if( currFibValue % 2 ==0) acc += currFibValue
}
println acc