Hello I am playing with the Ref{T} and I cannot understand why when doing some updates the changes are visible via the variable holding the Ref and when doing other updates they don’t show up. I would appreciate your help thank you .
mutable struct CommBoard
orders::Array{Int,1}
function CommBoard()
new(Array{Int,1}([]))
end
end
comm = CommBoard()
comm.orders = [20,35]
mycomm = Ref(comm)
function init_comm(comm::CommBoard)
comm.orders = []
return nothing
end
init_comm(comm)
println(comm) #returns CommBoard(Int64[])
println(mycomm[]) #returns CommBoard(Int64[])
comm.orders = [20,35]
println(comm) #returns CommBoard(Int64[20,35])
println(mycomm[]) #returns CommBoard(Int64[])
Thank I just restarted the Julia instance and it works as expected after I isolate I think another piece of code is interfering with it. Because It is not a a real problem I will just delete the post as I don’t see any value from it. Thank you very much for your response. (Like the reply so I can delete the post)