Dear Julia community,
I am trying to use the “!” prefix in order to modify a variable inside a function and have made this little test:
function test_copy!(a,b) a = b println("a in function: $a") end a = 0.0; b = 1.0; test_copy!(a,b) println("a outside function: $a")
The results are: “a in function: 1.0” and “a outside function: 0.0”.
So the variable a has not been modified by the call to test_copy!.
But if I do the same test with size(1) arrays
function test_equal_arrays!(vec,x) vec = x end vec = [0.0]; x = 1.0 test_equal_arrays!(vec,x) @show(vec)
I get “vec = [1.0]”.
So I am getting a little confused. Does someone knows how the “!” prefix work in that case ?
Thanks to all