I want to define a type alias for n-dimensional arrays of n-dimensional cartesian indices (so an array
that holds indices that are able to index that array). I tried
julia> MyType = Array{CartesianIndex{N},N} where N
and get as expected
julia> isa([CartesianIndex(1), CartesianIndex(2)], MyType)
true
but unlike wanted also
julia> isa([CartesianIndex(1,1), CartesianIndex(2,2)], MyType)
true
even though the dimensions don’t match in the second case. How do enforce that the dimensions
match in the type alias?
Bonus points if I can make it AbstractArray{CartesianIndex{N},N}
instead of Array
. So far
that also doesn’t work, probably because
julia> Vector{Int8} <: AbstractArray{Integer}
false