# .. broadcast object property

**URL:** <https://discourse.julialang.org/t/broadcast-object-property/47104>\
**Category:** Internals & Design\
**Tags:** question, broadcasting, structarrays\
**Created:** [September 23, 2020, 2:05am UTC](https://discourse.julialang.org/t/broadcast-object-property/47104 "2020-09-23T02:05:17Z")\
**Posts on this page:** 2\
**Page:** 3

<div class="post-metadata">

**Author:** ![Lincoln\_Hannah](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lincoln_hannah/32/19198_2.png) [@Lincoln\_Hannah](https://discourse.julialang.org/u/Lincoln_Hannah)\
**Post date:** [February 15, 2024, 3:54am UTC](https://discourse.julialang.org/t/broadcast-object-property/47104/42 "2024-02-15T03:54:05Z")

</div>

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

```julia
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?

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [February 15, 2024, 8:21am UTC](https://discourse.julialang.org/t/broadcast-object-property/47104/43 "2024-02-15T08:21:52Z")

</div>

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

```julia
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`?

[Previous page](https://discourse.julialang.org/t/broadcast-object-property/47104.md?page=2)
