Yes, this is expected. Have a look at the scope section of the manual, it also has examples on how to get the behaviour (I suspect) you want.
On Thu, 2015-02-05 at 16:26, Michael Francis <[email protected]> wrote: > 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
