"Locally global" variable?

You can use local on the level of of scope you want:

julia> function f()
         local x
         for i in 1:10
            for j in 1:10
               x = i*j
            end
         end
         x
       end
f (generic function with 1 method)

julia> f()
100


4 Likes