# Test for existence of a variable

**URL:** https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845
**Category:** New to Julia
**Tags:** question
**Created:** [July 10, 2020, 1:40pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845 "2020-07-10T13:40:32Z")
**Posts on this page:** 20
**Page:** 2

<div class="post-metadata">

### Author: ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)
#### Post date: [July 14, 2020, 10:02am UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/21 "2020-07-14T10:02:14Z")

</div>

> [@compleat](#):
>
> I tried to do as you suggested, but I couldn’t even figure out how to suggest a change/addition

Did you try clicking on the “Edit on Github” link at the top of the page you would like to contribute to?

After that, these instructions should be understandable and easy to follow:

> **[Editing files - GitHub Docs](https://docs.github.com/en/repositories/working-with-files/managing-files/editing-files)**
>
> You can edit files directly on GitHub in any of your repositories using the file editor.

You need to be signed in with a Github account - otherwise the “pencil” button won’t be active (step #2). And you won’t be able to commit directly to the master branch, only create a pull request (step #8), since you are not the owner of the repo. That’s all.

(EDIT. Better follow this: [Editing files - GitHub Docs](https://docs.github.com/en/github/managing-files-in-a-repository/editing-files-in-another-users-repository))

---

<div class="post-metadata">

### Author: ![compleat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compleat/32/8958_2.png) [@compleat](https://discourse.julialang.org/u/compleat)
#### Post date: [July 14, 2020, 10:21am UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/22 "2020-07-14T10:21:45Z")

</div>

Thanks, but I tried to navigate to where to edit, and didn’t get far. This is obviously something for someone with lots more time for this than I have got right now (I have already spent several hours just trying to help and have gotten nowhere). Thanks anyway.

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [July 14, 2020, 10:55am UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/23 "2020-07-14T10:55:29Z")

</div>

> [@compleat](#):
>
> if there were a sincere interest in engaging non-experts.

> [@compleat](#):
>
> This is obviously something for someone with lots more time for this than I have got right now (I have already spent several hours just trying to help and have gotten nowhere).

There _is_ a sincere interest in engaging more people: [contributing is described in detail](https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md) with [resources on Git/Github at the end](https://github.com/JuliaLang/julia/blob/master/CONTRIBUTING.md#resources), introductory issues are [labelled as such](https://github.com/JuliaLang/julia/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22), git workflow questions are answered on this forum, etc. It is of course conceivable that this could be done better, but since we do not know how you got stuck, this is not possible without your active involvement.

Again, it is perfectly fine if you don’t _want_ to contribute. Just don’t project your lack of interest/motivation on the community.

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [July 14, 2020, 12:29pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/24 "2020-07-14T12:29:01Z")

</div>

Most of the manual can be found in [this folder](https://github.com/JuliaLang/julia/tree/master/doc/src/manual), the specific file depends on which section you intend to edit.

I wrote a small reply on the process of contributing to a documentation by the Github interface [here](https://discourse.julialang.org/t/use-and-documentation-of-and/39882/7). You just need to ignore the link I pointed there and instead use the link to a file of the folder I linked above.

---

<div class="post-metadata">

### Author: ![compleat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compleat/32/8958_2.png) [@compleat](https://discourse.julialang.org/u/compleat)
#### Post date: [July 14, 2020, 12:43pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/25 "2020-07-14T12:43:00Z")

</div>

Hi. I tried. All I want to do is suggest addition of a simple example to the ‘Base@isdefined’ section of this page:  
[https://docs.julialang.org/en/v1/base/base/#Core.isdefined](https://docs.julialang.org/en/v1/base/base/#Core.isdefined)

But seeing how/where to do that seems extremely complicated, and (at the moment) way beyond me.

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [July 14, 2020, 12:46pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/26 "2020-07-14T12:46:56Z")

</div>

The example is at `@isdefined` (which is linked to from the docstring you linked):

[https://docs.julialang.org/en/v1/base/base/#Base.@isdefined](https://docs.julialang.org/en/v1/base/base/#Base.@isdefined)

This is the given example:

```julia
julia> function f()
           println(@isdefined x)
           x = 3
           println(@isdefined x)
       end
f (generic function with 1 method)

julia> f()
false
true

```

---

<div class="post-metadata">

### Author: ![compleat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compleat/32/8958_2.png) [@compleat](https://discourse.julialang.org/u/compleat)
#### Post date: [July 14, 2020, 12:54pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/27 "2020-07-14T12:54:04Z")

</div>

To me, that seems too abstract.  
I was thinking about the situation where x had not been defined. Then:

julia\> @isdefined x  
false

julia\> x=2  
2

julia\> @isdefined x  
true

For a ‘newbie’ (like my students, and even me) this seems much simpler to visualise.

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [July 14, 2020, 1:11pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/28 "2020-07-14T13:11:20Z")

</div>

I would like to point that, when you are with the mouse cursor over the documentation of this macro, a small blue “Source” button appears in the bottom-right.

Clicking it will give you the source code for that documentation, it will be the triple quoted string highlighted in yellow. You can then go to the top of the document, click in the “Tree: […]” dropdown below the “Code” tab and select “master” (in sub-tab branches) the page will reload. Now you can click the small pencil at right of the buttons “Raw” “Blame” (if it does not appear it is because you are not logged in Github, log in and come back there; if its not clickable and its hovertext is “You must be on a branch…” then you did not select “master” in the previous step).

Now you can go back to that line of the file and edit it (the file will be a writable form field now), unfortunately the lines will not be highlighted anymore so you need to search for it (or remember the line number). After the edit you can write a small title and description for your contribution (in the page bottom) and press “Propose changes”. This will create a PR (Pull Request) that will be analyzed by the Julia maintainers and if approved will change the documentation for the next Julia version.

---

<div class="post-metadata">

### Author: ![compleat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compleat/32/8958_2.png) [@compleat](https://discourse.julialang.org/u/compleat)
#### Post date: [July 14, 2020, 1:13pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/29 "2020-07-14T13:13:55Z")

</div>

OK- thanks. That sounds like kind of what I was hoping for but didn’t find.  
I’ll try again.

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [July 14, 2020, 1:15pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/30 "2020-07-14T13:15:52Z")

</div>

If you encounter any problems just ask. I tried to consider all possibilities, but I can be missing something.

---

<div class="post-metadata">

### Author: ![compleat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compleat/32/8958_2.png) [@compleat](https://discourse.julialang.org/u/compleat)
#### Post date: [July 14, 2020, 1:35pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/31 "2020-07-14T13:35:18Z")

</div>

When I click on the ‘Code’ tab, there is no ‘Tree’ dropdown, but rather a ‘Branch’ dropdown and ‘master’ is already selected by default, so nothing changes. I see no mention of ‘Tree’ anywhere.

---

<div class="post-metadata">

### Author: ![kristoffer.carlsson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/kristoffer.carlsson/32/22_2.png) [@kristoffer.carlsson](https://discourse.julialang.org/u/kristoffer.carlsson)
#### Post date: [July 14, 2020, 1:47pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/32 "2020-07-14T13:47:01Z")

</div>

> [@compleat](#):
>
> To me, that seems too abstract.  
> I was thinking about the situation where x had not been defined. Then:
> 
> ```julia
> julia> @isdefined x
> false
> 
> julia> x=2
> 2
> 
> julia> @isdefined x
> true
> 
> ```
> 
> For a ‘newbie’ (like my students, and even me) this seems much simpler to visualise.

I mean, that’s exactly what it shows? First when `x` is not defined, and then when it is defined.

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [July 14, 2020, 1:48pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/33 "2020-07-14T13:48:12Z")

</div>

I did not say to click the “Code” tab (clicking it does not remove you from the page of the file to the front page of the project?). I checked now and if you have a very high level of zoom the dropdown does not show “Tree” but instead just the commit code (screenshot below).

 ![2020-07-14-10:47:28_1920x1080](https://global.discourse-cdn.com/julialang/original/3X/d/1/d1a274abb0cfe5205db4acaff88b8e74a1435986.png)  
You were able to make the edit?

---

<div class="post-metadata">

### Author: ![compleat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compleat/32/8958_2.png) [@compleat](https://discourse.julialang.org/u/compleat)
#### Post date: [July 14, 2020, 2:16pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/34 "2020-07-14T14:16:56Z")

</div>

No, I wasn’t able to. I’m sorry, I just don’t have any more time for this. I tried to follow as best I could, but beyond clicking on ‘Source’ there are just too many buttons and possibilities and branches - it is all too complicated for me given that I just want something I can use and share with my students.

I do appreciate your trying to help, but I feel like my father used to when people would ask him about how his weekend was, when he often answered “I spent it fixing my labor-saving devices”. I would like Julia (and its documentation) to be something that enables me rather than distracts me away (e.g. for 4 hours today) from what I need to be spending time on.  
Thanks, though.

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [July 14, 2020, 2:24pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/35 "2020-07-14T14:24:11Z")

</div>

I created a PR [here](https://github.com/JuliaLang/julia/pull/36663) using the github UI for a more clear example based off of this discourse thread.

---

<div class="post-metadata">

### Author: ![compleat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compleat/32/8958_2.png) [@compleat](https://discourse.julialang.org/u/compleat)
#### Post date: [July 15, 2020, 4:25pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/36 "2020-07-15T16:25:56Z")

</div>

The exchange there has confirmed my suspicion that I won’t be able to use Julia for teaching any time soon.

Thanks, All.

---

<div class="post-metadata">

### Author: ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)
#### Post date: [July 15, 2020, 8:02pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/37 "2020-07-15T20:02:37Z")

</div>

I’m saddened that’s your conclusion from this thread and the pull request. It appears to me that you got the help you wanted and multiple people have engaged in trying to make the path smoother for those who come after you.

---

<div class="post-metadata">

### Author: ![compleat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compleat/32/8958_2.png) [@compleat](https://discourse.julialang.org/u/compleat)
#### Post date: [July 16, 2020, 12:11pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/38 "2020-07-16T12:11:24Z")

</div>

You misunderstand me. I didn’t say I was unappreciative nor that I didn’t get the help that I needed. I will continue to use Julia for my own work, just not for my teaching, - there just doesn’t seem to be anyone there listening to what I am saying about accessibility - it is just not part of the culture (yet).

---

<div class="post-metadata">

### Author: ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)
#### Post date: [July 16, 2020, 1:39pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/39 "2020-07-16T13:39:13Z")

</div>

> [@compleat](#):
>
> there just doesn’t seem to be anyone there listening to what I am saying about accessibility

I think it is particularly rude to say that no one was listening to you, after @Henrique_Becker provided step-by-step instructions for you to make the improvement in the docs, and when you announced that it was not worth your time, @pdeffebach contributed a PR implementing the change you asked for.

---

<div class="post-metadata">

### Author: ![compleat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compleat/32/8958_2.png) [@compleat](https://discourse.julialang.org/u/compleat)
#### Post date: [July 16, 2020, 1:47pm UTC](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845/40 "2020-07-16T13:47:06Z")

</div>

From what I could see, my contribution to the PR was just ridiculed and ignored.

[Previous page](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845.md?page=1)

[Next page](https://discourse.julialang.org/t/test-for-existence-of-a-variable/42845.md?page=3)
