# Undefined /out of scope

**URL:** https://discourse.julialang.org/t/undefined-out-of-scope/42188
**Category:** General Usage
**Created:** [June 28, 2020, 7:29am UTC](https://discourse.julialang.org/t/undefined-out-of-scope/42188 "2020-06-28T07:29:20Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![mayar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mayar/32/16426_2.png) [@mayar](https://discourse.julialang.org/u/mayar)
#### Post date: [June 28, 2020, 7:29am UTC](https://discourse.julialang.org/t/undefined-out-of-scope/42188/1 "2020-06-28T07:29:20Z")

</div>

Hello all,

I have been developing a code that executes a function using an array and now the problem started to happen when I put that function in a loop…I get the message saying that the array is not defined… I wrote the word global but it did not help  
Did anyone encounter this message or error before and what was the solution ?

Thank you

---

<div class="post-metadata">

### Author: ![mayar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mayar/32/16426_2.png) [@mayar](https://discourse.julialang.org/u/mayar)
#### Post date: [June 28, 2020, 7:30am UTC](https://discourse.julialang.org/t/undefined-out-of-scope/42188/2 "2020-06-28T07:30:45Z")

</div>

![dd](https://global.discourse-cdn.com/julialang/original/3X/0/a/0a987b9c7b15006f29a2726beb1fd15dbc4700e1.jpeg)  
 ![cc](https://global.discourse-cdn.com/julialang/original/3X/9/a/9af1eb812a568e56bae2dabff7ce7a805599728b.jpeg)

---

<div class="post-metadata">

### Author: ![oheil](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/oheil/32/220745_2.png) [@oheil](https://discourse.julialang.org/u/oheil)
#### Post date: [June 28, 2020, 8:20am UTC](https://discourse.julialang.org/t/undefined-out-of-scope/42188/3 "2020-06-28T08:20:00Z")

</div>

When you have eliminated **your code** , whatever remains must be an empty page.

> **PSA**
>
> > [@Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757):
> >
> > Welcome to the Julia Discourse! We are enthusiastic about helping Julia programmers, both beginner and experienced. This public service announcement (PSA) outlines best practices when asking for help. Following these points makes it easier for us to help you and more likely you’ll get a prompt, useful answer. Keywords are highlighted to make it easier to refer to specific points. Choose a descriptive title that captures the key part of your question, eg “plots with multiple axes” instead of …

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [June 28, 2020, 9:02am UTC](https://discourse.julialang.org/t/undefined-out-of-scope/42188/4 "2020-06-28T09:02:54Z")

</div>

It’s important to read error messages carefully. Your message says that you put the `global` keyword in the wrong place.

Can copy and paste the part of your code where you use `global`? Please copy the _text_, not an image of the text, and put triple quotes around the code.

---

<div class="post-metadata">

### Author: ![mayar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mayar/32/16426_2.png) [@mayar](https://discourse.julialang.org/u/mayar)
#### Post date: [June 29, 2020, 5:34am UTC](https://discourse.julialang.org/t/undefined-out-of-scope/42188/5 "2020-06-29T05:34:54Z")

</div>

Array=[1,1,1,1,1]

for i in 1:5

global Array[i]=Array[i]+1

end  
 ![ss](https://global.discourse-cdn.com/julialang/original/3X/2/1/21d3b11ae68e3f7ebdae1f48953ec94cdf24edcc.jpeg)

---

<div class="post-metadata">

### Author: ![mayar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mayar/32/16426_2.png) [@mayar](https://discourse.julialang.org/u/mayar)
#### Post date: [June 29, 2020, 5:36am UTC](https://discourse.julialang.org/t/undefined-out-of-scope/42188/6 "2020-06-29T05:36:00Z")

</div>

This is a simple code because i am afraid you get lost in the original code… but it resembles my code very much  
 ![ss](https://global.discourse-cdn.com/julialang/original/3X/2/1/21d3b11ae68e3f7ebdae1f48953ec94cdf24edcc.jpeg)

---

<div class="post-metadata">

### Author: ![mayar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mayar/32/16426_2.png) [@mayar](https://discourse.julialang.org/u/mayar)
#### Post date: [June 29, 2020, 5:38am UTC](https://discourse.julialang.org/t/undefined-out-of-scope/42188/7 "2020-06-29T05:38:46Z")

</div>

I donot get you…what do u mean by eliminated the code?

---

<div class="post-metadata">

### Author: ![tomaklutfu](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomaklutfu/32/2411_2.png) [@tomaklutfu](https://discourse.julialang.org/u/tomaklutfu)
#### Post date: [June 29, 2020, 5:39am UTC](https://discourse.julialang.org/t/undefined-out-of-scope/42188/8 "2020-06-29T05:39:14Z")

</div>

`Array` is already defined as a type name so you cannot make it another type. Choose another name for the variable.

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [June 29, 2020, 6:03am UTC](https://discourse.julialang.org/t/undefined-out-of-scope/42188/9 "2020-06-29T06:03:01Z")

</div>

This type of super-obscure communication will only be understood by those who are both very familiar with programming discussion fora _and_ Sherlock Holmes (_if_ I’m interpreting you correctly). It doesn’t appear very welcoming.

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [June 29, 2020, 6:06am UTC](https://discourse.julialang.org/t/undefined-out-of-scope/42188/10 "2020-06-29T06:06:07Z")

</div>

> [@mayar](#):
>
> what do u mean by eliminated the code?

Don’t worry about what was written, but look at the link (it’s this one [Please read: make it easier to help you](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757)). It will help you write your question in a way that makes it easier to answer.

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [June 29, 2020, 6:19am UTC](https://discourse.julialang.org/t/undefined-out-of-scope/42188/11 "2020-06-29T06:19:05Z")

</div>

The error message is telling you that the name `Array` is already defined when you start Julia:

```julia
[nils@nils-2560p /]$ julia
               _
   _ _ _(_)_ | Documentation: https://docs.julialang.org
  (_) | (_) (_) |
   _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` | |
  | | |_| | | | (_| | | Version 1.4.2 (2020-05-23)
 _/ |\ __'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |

julia> Array
Array

julia> typeof(Array)
UnionAll

```

this is what allows you to e.g. define an `Array{Float64}(undef, 5)`. Change the name or your array to `array` (lowercase) or `my_array` or whatever suits you.

As an aside, stylistic convention in Julia is that capitalized identifiers (such as `Array, Float64, Int` etc) are used for types, while variables / instances of a type have lowercase names.
