function test() x = 2 f = (()->x + 3) println( f() ) # Prints 5 Yeh! x = 4 println( f() ) # Prints 7 ??? g = (()->(x=4)) println( g() ) # Prints 4 Yeh, that should not be the same x println( x ) # Oops seems it is the same X println( f() ) # Yes seems there is one X here end
test() Prints - - 5 7 4 4 7 Is this the expected behavior for closures? it is not what I expected. This is in both 0.3.4 and 0.4.0-dev+3135