# Default ndims method for any type that HasShape{N}?

**URL:** <https://discourse.julialang.org/t/default-ndims-method-for-any-type-that-hasshape-n/91271>\
**Category:** Internals & Design\
**Created:** [December 5, 2022, 4:54pm UTC](https://discourse.julialang.org/t/default-ndims-method-for-any-type-that-hasshape-n/91271 "2022-12-05T16:54:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nchisholm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nchisholm/32/37414_2.png) [@nchisholm](https://discourse.julialang.org/u/nchisholm)\
**Post date:** [December 5, 2022, 4:54pm UTC](https://discourse.julialang.org/t/default-ndims-method-for-any-type-that-hasshape-n/91271/1 "2022-12-05T16:54:39Z")

</div>

Currently, if one defines, for example, `Base.IteratorSize(::MyMatrixLikeType) = Base.HasShape{2}()`, one still needs to define `Base.ndims(mymat::MyMatrixLikeType) = 2`. Would it make sense to have a method for `Base.ndims` that uses the type parameter of `HasShape` so there is no need to manually define `ndims`?
