I just wanted to double-check that I understand it correctly: doing a 
vectorized operation to a passed variable inside a function will not change 
the variable on the outside? Does one have to resort to a `for` loop, or is 
there another way?

function foo!(x)

    x += 10

end

 

function bar!(x)
    [ x[i] += 10 for i in 1:size(x,1) ]
end

 

y = [1:3]

 

foo!(y)

println(y)

 

bar!(y)

println(y)


Output:

[1,2,3]

[1,2,3]

[11,12,13]


Thanks. 

Reply via email to