# Wher variable "j" is declared as local?

**URL:** <https://discourse.julialang.org/t/wher-variable-j-is-declared-as-local/24734>\
**Category:** General Usage\
**Created:** [May 29, 2019, 1:31pm UTC](https://discourse.julialang.org/t/wher-variable-j-is-declared-as-local/24734 "2019-05-29T13:31:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [May 29, 2019, 1:31pm UTC](https://discourse.julialang.org/t/wher-variable-j-is-declared-as-local/24734/1 "2019-05-29T13:31:26Z")

</div>

```julia
julia> function my_fu()
           global j
           println(j)
       end
my_fu (generic function with 1 method)

julia> for j=1:3
            global j
            my_fu()
        end
ERROR: syntax: variable "j" declared both local and global

```

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [May 29, 2019, 1:40pm UTC](https://discourse.julialang.org/t/wher-variable-j-is-declared-as-local/24734/2 "2019-05-29T13:40:31Z")

</div>

You are implicitly declaring `j` locally in your `for` loop.

Try

```julia
for i ∈ 1:3 
    global j = i
    my_fu()
end

```

---

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [May 29, 2019, 1:52pm UTC](https://discourse.julialang.org/t/wher-variable-j-is-declared-as-local/24734/3 "2019-05-29T13:52:36Z")

</div>

> [@ExpandingMan](#):
>
> ∈

Works, why ?🙂

```julia
∈== in

```

?

---

<div class="post-metadata">

**Author:** ![ExpandingMan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/expandingman/32/866_2.png) [@ExpandingMan](https://discourse.julialang.org/u/ExpandingMan)\
**Post date:** [May 29, 2019, 1:56pm UTC](https://discourse.julialang.org/t/wher-variable-j-is-declared-as-local/24734/4 "2019-05-29T13:56:01Z")

</div>

> [@programista](#):
>
> ∈

It’s just an alternate syntax that’s available in Julia. It is exactly equivalent to `in`. Note that if you are using a Julia (or other latex-to-unicode) plugin on your editor you can just type in `\in`, either hit tab or space, and the replacement will be made for you.

Of course, this has nothing to do with why your original code was failing.
