I use Julia 1.6.2 & Juno, and I have this code:
println("0.5772156649015328606065120900824024310421")
jmax = 1000000
gamma = 0
j = 1
for j = jmax:-1:1
gamma = gamma + 1.e0/j
end
gamma = gamma - log(jmax)
println("$gamma, reverse order sum $(jmax)")
There is no error when I run each line in order by using Ctrl+Enter. But I have an error and get the following message when I do 'run all' (Ctrl+Shift+Enter).
Warning: Assignment to 'gamma' in soft scope is ambiguous because a global variable by the same name exists: 'gamma' will be treated as a new local. Disambiguate by using 'local gamma' to suppress this warning or 'global gamma' to assign to the existing global variable.
ERROR: LoadError: UndefVarError: gamma not defined
I don't know why this difference happens. Can you explain about it?