If I have a vector of structs say s, I know I can set and get a field for all elements at once by using setfield!. and getfield. . Is there a convenient way of ensuring that I can use s.x . I guess there is scope for ambiguity, but I’m ok with having s.x being a view.
Thanks!
mutable struct S
x
y
end
function runme()
s = [ S( randn( 2 )...) for j ∈ 1:3 ]
s2 = [ S( randn( 2 )...) for j ∈ 1:3 ]
println( s )
println( s2 )
setfield!.( s, :x, getfield.( s2, :y ) .+ 1 )
# would like to write s.x = s2.y .+ 1
println( s )
end