# Get new type with different parameter

**URL:** https://discourse.julialang.org/t/get-new-type-with-different-parameter/37253
**Category:** New to Julia
**Created:** [April 8, 2020, 11:06pm UTC](https://discourse.julialang.org/t/get-new-type-with-different-parameter/37253 "2020-04-08T23:06:20Z")
**Posts on this page:** 1
**Showing post:** 5

<div class="post-metadata">

### Author: ![mauro3](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mauro3/32/292_2.png) [@mauro3](https://discourse.julialang.org/u/mauro3)
#### Post date: [April 8, 2020, 11:36pm UTC](https://discourse.julialang.org/t/get-new-type-with-different-parameter/37253/5 "2020-04-08T23:36:51Z")

</div>

Have a read through:  
[https://docs.julialang.org/en/v1/manual/methods/#Extracting-the-type-parameter-from-a-super-type-1](https://docs.julialang.org/en/v1/manual/methods/#Extracting-the-type-parameter-from-a-super-type-1)

The thing is, that parameters might change place, or don’t exist (see the `BitVector` example). Thus, it is generally not a good idea to do this. If you still want to do it, you probably want a generated function:

```julia
julia> @generated function newT(::Type{T}, ::Type{TT}) where {T,TT}
           getfield(parentmodule(T), nameof(T)){TT}
       end
newT (generic function with 2 methods)

julia> newT(Array{Int,2}, Float64)
Array{Float64,N} where N

```

adapted from [https://github.com/JuliaObjects/ConstructionBase.jl/blob/b5686b755bd3bee29b181b3cb18fe2effa0f10a2/src/ConstructionBase.jl#L25](https://github.com/JuliaObjects/ConstructionBase.jl/blob/b5686b755bd3bee29b181b3cb18fe2effa0f10a2/src/ConstructionBase.jl#L25).

---

_[View the full topic](https://discourse.julialang.org/t/get-new-type-with-different-parameter/37253)._
