I have a very basic question that I can’t wrap my head around. I’m having some trouble understanding the following behavior:
for i in 1:2 if i == 1 a = 1 else a += 1 end end # ERROR: UndefVarError: a not defined
I expect that
a should be defined on the first iteration of the loop and, since it belongs to the for loop’s scope, it should be available on the second iteration of the loop.
Sorry for such a basic question and thanks!