having a set of matrices, when looping through them and modifying them, I'm unable to delete them from the set:
julia> grids = Set([[1 2;3 4],[3 4;5 6]])
Set{Matrix{Int64}} with 2 elements:
[1 2; 3 4]
[3 4; 5 6]
julia> for g in grids
g[g .== 3] .= 0
println(g)
println(grids)
delete!(grids,g)
end
[1 2; 0 4]
Set([[1 2; 0 4], [3 4; 5 6]])
[0 4; 5 6]
Set([[1 2; 0 4], [0 4; 5 6]])
julia> println(grids)
Set([[1 2; 0 4], [0 4; 5 6]])
however manual delete works:
julia> grids = Set([[1 2;3 4],[3 4;5 6]])
Set{Matrix{Int64}} with 2 elements:
[1 2; 3 4]
[3 4; 5 6]
julia> delete!(grids, [1 2;3 4])
Set{Matrix{Int64}} with 1 element:
[3 4; 5 6]
What am I missing please? I assumed the g in the loop behaves like a pointer to certain matrix, but it doesn't. Clearly, I am missing some Julia concept here...