# Inner constructors with parametric types, can't seem to get them to work for me

**URL:** <https://discourse.julialang.org/t/inner-constructors-with-parametric-types-cant-seem-to-get-them-to-work-for-me/31337>\
**Category:** General Usage\
**Tags:** question\
**Created:** [November 21, 2019, 7:29am UTC](https://discourse.julialang.org/t/inner-constructors-with-parametric-types-cant-seem-to-get-them-to-work-for-me/31337 "2019-11-21T07:29:16Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [November 21, 2019, 7:39am UTC](https://discourse.julialang.org/t/inner-constructors-with-parametric-types-cant-seem-to-get-them-to-work-for-me/31337/2 "2019-11-21T07:39:58Z")

</div>

Your inner constructor defines a method with type parameters in the signature (the `{ ... }` part). Unless you really need it, I would recommend just using types from the call signature. Also, you don’t need to store the type `T` in a slot `b` explicitly. I would do something like this instead:

```julia
struct Test{T, N, A} <: AbstractArray{T, N}
    a::Dict{NTuple{N, Int}, String}
    c::A
    d::Array{T, 2}
    function Test(::Type{T}, a::Dict{NTuple{N,Int},String}, c::A) where {T, N, A}
        new{T,N,A}(a, c, Array{T}(undef, 10, 10))
    end
end

# this works, but printing fails because you need to define a method 
# for `getindex` and `size` so that # `show` works, or alternatively 
# define the latter
z = Test(Float64, Dict((1,2,3,4)=>"test"), 6);

```

---

_[View the full topic](https://discourse.julialang.org/t/inner-constructors-with-parametric-types-cant-seem-to-get-them-to-work-for-me/31337)._
