Why does the soft scope warning not appear in a nested loop?

You can always declare a variable as local to avoid it picking up any previous definitions:

function f()
   i = 100
   for j in 1:2
       local i = 0
       i = i + j
   end
   println(i)
end

julia> f()
100
7 Likes