Array of Structs: getindex, slicing, and broadcasting getfield

I would suggest defining an accessor function and then broadcasting that function:

id(s::State) = s.ID

id.(states)

Does that work for your use case?

3 Likes