Imagine we have an array and we want to change it inside a function:
function set_ones!(x) x[:,:] .= 1 end arr = zeros(5) set_ones!(arr) println(arr)
It works just as expected. Result:
[1.0, 1.0, 1.0, 1.0, 1.0]
But if we want change only part of the array:
arr2 = zeros(5) set_ones!(arr2[1:3]) println(arr2)
[0.0, 0.0, 0.0, 0.0, 0.0]
Is it how it supposed to work, or is it a bug?