# How to dispatch this serializer function?

**URL:** <https://discourse.julialang.org/t/how-to-dispatch-this-serializer-function/65981>\
**Category:** Performance\
**Tags:** dispatch\
**Created:** [August 7, 2021, 6:17am UTC](https://discourse.julialang.org/t/how-to-dispatch-this-serializer-function/65981 "2021-08-07T06:17:12Z")\
**Posts on this page:** 1\
**Showing post:** 32

<div class="post-metadata">

**Author:** ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)\
**Post date:** [August 9, 2021, 1:30pm UTC](https://discourse.julialang.org/t/how-to-dispatch-this-serializer-function/65981/32 "2021-08-09T13:30:11Z")

</div>

I think this reduces to

```julia
dimensions(x) = UInt8(0)
dimensions(x::Union{String, Tuple}) = (UInt8(1), UInt32(length(x)))
dimensions(x::AbstractArray) = (UInt8(ndims(x)), UInt32.(size(x))...)

```

---

_[View the full topic](https://discourse.julialang.org/t/how-to-dispatch-this-serializer-function/65981)._
