Skip to content

CartesianIndex cannot iterate/splat #21148

@andyferris

Description

@andyferris

It seems unusual to me that the indexable CartesianIndex cannot also iterate (or splat).

julia> start(Base.CartesianIndex(1))
ERROR: MethodError: no method matching start(::CartesianIndex{1})
Closest candidates are:
  start(::SimpleVector) at essentials.jl:259
  start(::Base.MethodList) at reflection.jl:561
  start(::ExponentialBackOff) at error.jl:107

For context, I had tried this for creating an expression in a generated function by splatting out the Cartesian indices (so run-time performance of iteration vs. indexing isn't an issue). The (or rather, my) workaround is significantly less elegant.

Metadata

Metadata

Assignees

No one assigned

    Labels

    arrays[a, r, r, a, y, s]

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions