I was confused with the following function that modify the vector “as a whole” v.s. the link Performance Tips · The Julia Language. My function does not change the vector. Why will it behave differently?
Thank you everybody for the help.
a = randn(100)
copy_of_a = copy(a)
function modified!(a, copy_of_a)
a = randn(100)
sum(a .!= copy_of_a) #inside the function it was modified
end
modified!(a, copy_of_a)
sum(a .!= copy_of_a) #but outside the function a still is the original