.. broadcast object property

Thanks so much:)
Have to be a bit careful when combining unwrap and LazyRows.

mutable struct ABC  <: StaticArrays.FieldVector{3, Int64};  a::Int64; b::Int64; c::Int64 end
mutable struct HIJ  <: StaticArrays.FieldVector{3, Int64};  h::Int64; i::Int64; j::Int64 end

@kwdef mutable struct X
    abc::ABC
    hij::HIJ
end

SA = StructArray( [
        X( ABC(1,1,1), HIJ(1,1,1)  )
        X( ABC(2,2,2), HIJ(2,2,2)  )
        X( ABC(3,3,3), HIJ(3,3,3)  )
    ],
    unwrap = t-> t<:ABC
    )
    

function f1!(x::Union{X,LazyRow{X}})   #need to include LazyRow{X}
    x.abc .= [10,10,10]
    x.hij .= [10,10,10]
end

function f2!(x::Union{X,LazyRow{X}})
    x.abc = [100,100,100]
    x.hij = [100,100,100]
end


f1!.(SA)                #alters hij 
f1!.(LazyRows(SA))      #alters hij
f2!.(SA)                #no effect
f2!.(LazyRows(SA))      #alters both abc and hij

#Interesting that f1!.(LazyRows(SA))  doesn't alter abc

I guess best not to unwrap something if you want to alter it at a Struct level.

Would it be possible to unwrap abc and re-wrap it as a 2D KeyedArray?

It looks like broadcast assignment is not implemented for lazy rows?

LazyRow(SA, 1).abc .= [0,0,0] # doesn't alter abc

Maybe file an issue on GitHub…

By the way note that X doesn’t need to be mutable if you only change it through lazy rows!

Could you give an example of what you want with KeyedArray?