# Parametric-type definition

**URL:** <https://discourse.julialang.org/t/parametric-type-definition/58873>\
**Category:** New to Julia\
**Tags:** type, parametric-types\
**Created:** [April 8, 2021, 7:26pm UTC](https://discourse.julialang.org/t/parametric-type-definition/58873 "2021-04-08T19:26:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Germinator](https://avatars.discourse-cdn.com/v4/letter/g/3be4f8/32.png) [@Germinator](https://discourse.julialang.org/u/Germinator)\
**Post date:** [April 8, 2021, 7:26pm UTC](https://discourse.julialang.org/t/parametric-type-definition/58873/1 "2021-04-08T19:26:30Z")

</div>

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

```julia
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:

```julia
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?

---

<div class="post-metadata">

**Author:** ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)\
**Post date:** [April 8, 2021, 7:32pm UTC](https://discourse.julialang.org/t/parametric-type-definition/58873/2 "2021-04-08T19:32:55Z")

</div>

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

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

```

---

<div class="post-metadata">

**Author:** ![Germinator](https://avatars.discourse-cdn.com/v4/letter/g/3be4f8/32.png) [@Germinator](https://discourse.julialang.org/u/Germinator)\
**Post date:** [April 8, 2021, 10:37pm UTC](https://discourse.julialang.org/t/parametric-type-definition/58873/3 "2021-04-08T22:37:45Z")

</div>

Thank you so much!
