The docs say
In Julia, all arguments to functions are passed by reference.
so I was quite surprised to see a difference in the behaviour of these two functions:
function foo!(r::Array{Int64})
r=r+1
end
function foobar!(r::Array{Int64})
for i=1:length(r)
r[i]=r[i]+1
end
end
here is the unexpectedly different output:
julia> myarray
2-element Array{Int64,1}:
0
0
julia> foo!(myarray);
julia> myarray
2-element Array{Int64,1}:
0
0
julia> foobar!(myarray);
julia> myarray
2-element Array{Int64,1}:
1
1
if the array is passed by reference, I would have expected foo! to change the zeros to ones.