# "Locally global" variable?

**URL:** <https://discourse.julialang.org/t/locally-global-variable/60471>\
**Category:** General Usage\
**Tags:** scope\
**Created:** [May 3, 2021, 4:49pm UTC](https://discourse.julialang.org/t/locally-global-variable/60471 "2021-05-03T16:49:50Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [May 3, 2021, 4:59pm UTC](https://discourse.julialang.org/t/locally-global-variable/60471/4 "2021-05-03T16:59:05Z")

</div>

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

```julia
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

```

---

_[View the full topic](https://discourse.julialang.org/t/locally-global-variable/60471)._
