Skip to content

Static arrays: index & property access #261

@aplavin

Description

@aplavin

Static arrays support accessing by index or by property name:

julia> using StaticArrays, StructArrays

julia> v = SVector(1, 2)

julia> v[1]
1

julia> v.x
1

However, a struct array of static arrays can only retrieve components by index:

julia> a = StructArray([v])
1-element StructArray(::Vector{Int64}, ::Vector{Int64}) with eltype SVector{2, Int64}:
 [1, 2]

julia> a.:1
1-element Vector{Int64}:
 1

julia> a.x
ERROR: type Tuple has no field x

Can both be supported? I understand this isn't straightforward, but would be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions