affans
January 18, 2019, 2:28pm
11
The not-so-obvious scoping rules you see has been discussed quite a bit over the last year or so. It’s a contentious issue and as far as I am aware, no solution was agreed upon.
Hi Guys, i’m having the same problem in Jupyter Notebook. I’m creating my own Julia tutorial following the youtube “Intro to Julia” video.
In a code cell I made it:
n=0
while n < 10
println(n)
n+=1
end
And the result was:
UndefVarError: n not defined
Stacktrace:
[1] top-level scope at ./In[18]:3 [inlined]
[2] top-level scope at ./none:0
I’ve tried to put the local status in any place but the result still goes wrong, the solution came following @saschatimme instructions (or at leas…
It is not a bug.
It worked in Julia 0.6, in Julia 0.7 it gave a deprecation warning that you must add global, and in 1.0 it throws an error.
I really like favba’s idea of starting by introducing functions and teaching them to write tiny functions. Sounds like that’d also end up encouraging good coding habits.
And many more threads.
1 Like