Ok, what missed from the example before was just the
copy_settings()
This does what you want (only for :z):
function StructArrays.component(s::StructArray, key)
if key == :z
return last.(getfield(StructArrays.components(s), :Z))
end
getfield(StructArrays.components(s), key)
end
But, if this is a good idea or good style I doubt.
E.g. what if another StructArray has some field z?