# Value Function - Scoping problem

**URL:** <https://discourse.julialang.org/t/value-function-scoping-problem/20236>\
**Category:** New to Julia\
**Tags:** economics\
**Created:** [January 29, 2019, 4:18pm UTC](https://discourse.julialang.org/t/value-function-scoping-problem/20236 "2019-01-29T16:18:41Z")\
**Posts on this page:** 1\
**Showing post:** 10

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [January 29, 2019, 9:01pm UTC](https://discourse.julialang.org/t/value-function-scoping-problem/20236/10 "2019-01-29T21:01:38Z")

</div>

You’ve got a lot of code here, so it’s hard to be sure, but I would suspect that the problem is here:

```julia
V = V_new

```

in Matlab, this would _copy_ `V_new` and create a new vector called `V`. Any future changes to `V_new` would not affect `V`. In Julia, however, this just makes `V` a label for the _same_ vector as `V_new`, so any changes to `V_new` will be shared with `V`. This is actually how _all_ assignment operations in Julia work: Julia doesn’t silently copy things when you assign them or when you pass them to functions (unlike Matlab).

If you do want a copy, you can simply do: `V = copy(V_new)`.

Perhaps that will help you figure out what’s different in the results you’re seeing.

---

_[View the full topic](https://discourse.julialang.org/t/value-function-scoping-problem/20236)._
