I'm using Julia 1.1 and I tried to use for loop do the following simple things:
i_index=1;
for index in (1:100)
i_index=i_index+1;
end
However, I got an error saying:
ERROR: UndefVarError: i_index not defined
I have tried several times and variations, but they all failed to work. Is this a bug? or why Julia can't do this simple iterative addition?
global
, like this:global i_index=i_index+1;
– Sebastian Kaczmarek Apr 1 '19 at 6:19i_index
in a global scope so you need to access it usingglobal
. In a function your code would work as is – Sebastian Kaczmarek Apr 1 '19 at 6:26