Parametric-type definition

Hi all! I have a question defining a parametric type which I defined, subtype of AbstractArray:

struct CoreM{N} <: AbstractArray{Float64,N}
    core::Array{Float64,N}
end

I would like to define a CoreM type, which is subtype of AbstractArray{T,3} for fixed N=3 but for type any type T<:Number, something like:

struct CoreM2{T} <: AbstractArray{T,3} where T<:Number
    core::Array{T,3}
end

which however gives me error: ERROR: invalid subtyping in definition of CoreM2
Can this be accomplished?

Yup, you just need to move the <:Number around:

julia> struct CoreM2{T <: Number} <: AbstractArray{T, 3}
         core::Array{T, 3}
       end
2 Likes

Thank you so much!