Understanding while loop UndedVarError and scope

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).