# Tricky parametric type dispatch

**URL:** https://discourse.julialang.org/t/tricky-parametric-type-dispatch/23064
**Category:** General Usage
**Tags:** parametric-types
**Created:** [April 12, 2019, 5:33am UTC](https://discourse.julialang.org/t/tricky-parametric-type-dispatch/23064 "2019-04-12T05:33:10Z")
**Posts on this page:** 1
**Showing post:** 2

<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 12, 2019, 6:18am UTC](https://discourse.julialang.org/t/tricky-parametric-type-dispatch/23064/2 "2019-04-12T06:18:16Z")

</div>

No, you cannot do this in general. This is why `similar` exists for arrays and you should probably use a similar approach. X-ref:

> [@Stripping parameter from parametric types](https://discourse.julialang.org/t/stripping-parameter-from-parametric-types/8293/10):
>
> No, you can’t. The approved solution is wrong – there’s no relation between the ordering of type parameters of a subtype (in this case, SomeArrayType) and its supertype (AbstractArray). Tamas\_Papp’s solution is correct. In generic code, this is usually done by calling the similar function. However, we can also generalize that solution to abstract types as follows (by adding in \<: so that it can select subtypes): stripN(::Type{\<:AbstractArray{T, N}}) where {T, N} = AbstractArray{T, M} where M

---

_[View the full topic](https://discourse.julialang.org/t/tricky-parametric-type-dispatch/23064)._
