# When will the original value be changed with the copied value?

**URL:** https://discourse.julialang.org/t/when-will-the-original-value-be-changed-with-the-copied-value/37810
**Category:** New to Julia
**Tags:** question
**Created:** [April 18, 2020, 4:53pm UTC](https://discourse.julialang.org/t/when-will-the-original-value-be-changed-with-the-copied-value/37810 "2020-04-18T16:53:14Z")
**Posts on this page:** 1
**Showing post:** 6

<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: [April 19, 2020, 12:00am UTC](https://discourse.julialang.org/t/when-will-the-original-value-be-changed-with-the-copied-value/37810/6 "2020-04-19T00:00:18Z")

</div>

I did not find the specific section of the manual that explains this, so I will try to explain it myself (but I am almost sure such section exists).

The problem I see is that your mental model on how variables and objects work is not how they work in Julia (but I am sure in other languages you would see the behavior you did expect).

In Julia, a variable is just a name for some value in some scope. When you attribute a value to some variable you are never copying it, you are _binding_ it, this is: just giving it a name so it can be referred later (and is not collected by garbage collection in the meantime). In C/C++ and other languages, variables are specific places in memory, and when you attribute something to a variable you are always copying something, be it the value you are interested or just a pointer to it. In julia making `x = y` is no different than saying, “oh, this thing I am calling `y` right now, well, now `x` is another name for it”. So, when in your second example you do:

```julia
solution = ones(4)
solution_temp = solution
solution_temp = [2.,2.,2.,2.]

```

It can be read as:

1. `solution` is the name for the return of `ones(4)`;
2. `solution_temp` is also a name for the same thing;
3. nevermind, `solution_temp` is instead a name for this brand new vector or twos;

---

_[View the full topic](https://discourse.julialang.org/t/when-will-the-original-value-be-changed-with-the-copied-value/37810)._
