# Array definition error

**URL:** <https://discourse.julialang.org/t/array-definition-error/22181>\
**Category:** General Usage\
**Tags:** question\
**Created:** [March 22, 2019, 7:12am UTC](https://discourse.julialang.org/t/array-definition-error/22181 "2019-03-22T07:12:15Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)\
**Post date:** [March 22, 2019, 7:28am UTC](https://discourse.julialang.org/t/array-definition-error/22181/2 "2019-03-22T07:28:48Z")

</div>

You need to add a `global` to your `u`:

```julia
    ....
    global u
    u = u_new
end

```

But note that after above statement your `u` and `u_new` point to the same array, which is probably not what you want. Probably best to swap bindings:

```julia
    ....
    global u, u_new
    u, u_new = u_new, u
end

```

Next time, please post a minimal, working (or erroring) example to make it easy on your helpers: [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757)

Also, note that running stuff in global scope, i.e. not in a function is not performant. Check the performance-tips of the docs.

---

_[View the full topic](https://discourse.julialang.org/t/array-definition-error/22181)._
