# Understanding while loop UndedVarError and scope

**URL:** <https://discourse.julialang.org/t/understanding-while-loop-undedvarerror-and-scope/16609>\
**Category:** General Usage\
**Created:** [October 21, 2018, 7:07pm UTC](https://discourse.julialang.org/t/understanding-while-loop-undedvarerror-and-scope/16609 "2018-10-21T19:07:41Z")\
**Posts on this page:** 1\
**Showing post:** 14

<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:** [October 23, 2018, 6:24pm UTC](https://discourse.julialang.org/t/understanding-while-loop-undedvarerror-and-scope/16609/14 "2018-10-23T18:24:46Z")

</div>

`global` is needed to rebind a variable which is a completely different thing from mutating a container.

`v[1] = 1` is just pretty syntax for `setindex!(v, 1, 1)`.

---

_[View the full topic](https://discourse.julialang.org/t/understanding-while-loop-undedvarerror-and-scope/16609)._
