Dear all,
I am trying to increment the value of a variable with this loop:
julia> p=0
0
julia> for i in 1:10
p += 1
end
ERROR: UndefVarError: p not defined
Stacktrace:
[1] top-level scope at ./none:2
I also tried with:
julia> p=Int8
Int8
julia> for i in 1:10
p += 1
end
ERROR: UndefVarError: p not defined
Stacktrace:
[1] top-level scope at ./none:2
Isn’t +=
the increment operator? Even if I declare the variable as global (which I think is an overkill) the error persists:
julia> global p=0
0
julia> for i in 1:10
p += 1
end
ERROR: UndefVarError: p not defined
Stacktrace:
[1] top-level scope at ./none:2
What am I getting wrong? Thank you.