That's exactly my question: Why should defining a function inside the loop mess with the variables in the loop?
On Wednesday, April 29, 2015 at 10:33:03 AM UTC-4, Sisyphuss wrote: > > Another *miracle* here is that if you delete "g()=2z", there will be no > error! > > > On Wednesday, April 29, 2015 at 3:53:23 PM UTC+2, Pooya wrote: >> >> Can someone explain why this is the desired behavior? z is defined until >> the end of first iteration in the for loop, but not in the beginning of the >> next: >> >> julia> for i=1:10 >> if i>=2; println(z); end >> z=2 >> g()=2z >> println(z) >> end >> 2 >> ERROR: z not defined >> in anonymous at no file:2 >> >
