Hi everyone.
I am using a mutate function that changes the value of an array and then I save the array to a dictionary.
The problem is that the function changes all the values saved in the dictionary.
a = Dict()
b = ones(2,2)
function update_b!(b)
b .= b .+1
end
for i in 1:2
update_b!(b)
a[i] = b
end
The result of a:
2 => [3.0 3.0; 3.0 3.0]
1 => [3.0 3.0; 3.0 3.0]
I would like something like:
2 => [3.0 3.0; 3.0 3.0]
1 => [2.0 2.0; 2.0 2.0]
Using the function with a return fixes the problem, but I would like to know if the problem can be fixed with a mutable function.