Stripping parameter from parametric types

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
2 Likes