#1408 Closure variable binding bug? (fansh)

tcolar Fri 4 Feb 2011

Executing:

fansh> counter := 0

0

fansh> f := |->Int| { return ++counter }

|->sys::Int|

fansh> f()

1

fansh> f()

2

fansh> echo(counter)

0

shouldn't echo(counter) say "2" ???

brian Fri 4 Feb 2011

The way fansh works, it doesn't quite work the way normal code would for local variables. So for testing out closures you should probably use a script

Login or Signup to reply.