I have seen a behaviour that confused me a little bit. I have a list with structs (list_of_structs) and I selected specific indices of it with an integer array (idx_array). When I then manipulate structs of the list_of_structs, which had the same index of the idx_array, I manipulate all of them. After that I used deepcopy, but this led to the same behaviour. Then I used the broadcast version of deepcopy, which works fine, but now I´m not sure when I have to use deepcopy() and when deepcopy.().
list_of_structs = deepcopy(list_of_strucs[idx_array])
list_of_structs = deepcopy.(list_of_strucs[idx_array])
In example I have a struct with multiple different data types in it, including a list of structs as in the example above. Do I have to use deepcopy() or deepcopy.() to make independent copy of my_struct1 ?
mutable struct MyStruct2
var1::Array{Int64}
var2::Float64
end
mutable struct MyStruct1
list_of_structs::Array{MyStruct2}
var1::Int64
var2::DataFrame
end