Hello,
I have created some variable in the mainstream of a Julia stream; in order to pass them (to be modified) inside a for loop, I first declared them as global
.
For instance;
global a = 10
for i in 1:100
b = a*2
a = b*0.1
end
give the error:
UndefvarError: a is not defined
If I define global inside the loop as well, I get:
global a = 10
for i in 1:100
b = global a*2
a = b*0.1
end
> syntax: invalid syntax in "global" declaration
if I define the variable as global before giving any value, I still get the undefined error:
global a = Int8[]
a = 10
for i in 1:100
b = a*2
a = b*0.1
end
> UndefVarError: a not defined
I am still confused on how to pass values from the main to the loops in Julia. Any help, please?
Thank you.