Your function is binding the symbol a to a new array, not mutating the outside one. Here’s a way to see it:
julia> @show a[1] objectid(a); # old
a[1] = 0.9312276078859445
objectid(a) = 0x0835e8e05a663b75
julia> function modified!(a, copy_of_a)
@show a[1] objectid(a) # old
a = randn(100)
@show a[1] objectid(a) # new
sum(a .!= copy_of_a) #inside the function it was modified
end
modified! (generic function with 1 method)
julia> modified!(a, copy_of_a)
a[1] = 0.9312276078859445
objectid(a) = 0x0835e8e05a663b75
a[1] = 0.18746827198090105
objectid(a) = 0x828f4d79978ef50d
100
If you wrote a .= randn(100) or copyto!(a, rand(100)), or just a .= randn.(), then instead the values inside a would be altered.