Skip to content

Indexing a ComponentArray with an array of symbols #71

@scheidan

Description

@scheidan

Sorry for the clumpsy title, I hope the example makes the idea clearer:

ca = ComponentVector(a=1, b=2, c=3)

ca[[1,2]]                # works
ca[[1,2]] .= [-1, -2]    # works

# Similar, it would be nice to index multiple fields with an array of symbols
ca[[:a, :b]]                # doesn't work
ca[[:a, :b]] .= [-11, -22]  # doesn't work

# This works, but is not quite as elegant:
getindex.(Ref(p1), [:a, :b])
setindex!.(Ref(ca), [-11, -22], [:a, :b])

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