# Modify global variable in a function

**URL:** <https://discourse.julialang.org/t/modify-global-variable-in-a-function/47831>\
**Category:** General Usage\
**Tags:** question\
**Created:** [October 6, 2020, 3:41am UTC](https://discourse.julialang.org/t/modify-global-variable-in-a-function/47831 "2020-10-06T03:41:41Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jea](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jea/32/18457_2.png) [@Jea](https://discourse.julialang.org/u/Jea)\
**Post date:** [October 6, 2020, 3:41am UTC](https://discourse.julialang.org/t/modify-global-variable-in-a-function/47831/1 "2020-10-06T03:41:41Z")

</div>

I want to rename a variable in a function for later use with its new value.

What I was thinking was this:

```julia
myVar = ""

function renameVar()
     myVar = "Hello"
end

renameVar()

println(myVar) #What I wanted is for it to show **Hello** here

```

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [October 6, 2020, 3:52am UTC](https://discourse.julialang.org/t/modify-global-variable-in-a-function/47831/2 "2020-10-06T03:52:46Z")

</div>

[https://docs.julialang.org/en/v1/manual/variables-and-scoping/#On-Soft-Scope](https://docs.julialang.org/en/v1/manual/variables-and-scoping/#On-Soft-Scope)
