New to Julia and programming in general, sorry in advance for any faux pas. Here I define a structure S with a field f which expects a vector of integers.
mutable struct S
f::Vector{Int64}
S(x) = new(x)
end
end
Now I define two S structures, with the field of Sb taken from Sa
Sa = S([1,2])
Sb = S(Sa.f)
However, if I now change a value in Sb.f
Sb.f[1] = 3
the same change applies to Sa.f as well
Sa.f[1] == Sb.f[1]
returns true
Is this behavior intended? How would I change values in Sb.f without affecting Sa.f? My current workaround is simply
Sb = S(Sa.f + 0)
Am I doing something weird here?