# Dispatch on size of MVectors

**URL:** <https://discourse.julialang.org/t/dispatch-on-size-of-mvectors/74685>\
**Category:** New to Julia\
**Created:** [January 15, 2022, 9:05pm UTC](https://discourse.julialang.org/t/dispatch-on-size-of-mvectors/74685 "2022-01-15T21:05:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lrnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lrnv/32/19373_2.png) [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Post date:** [January 15, 2022, 9:05pm UTC](https://discourse.julialang.org/t/dispatch-on-size-of-mvectors/74685/1 "2022-01-15T21:05:01Z")

</div>

Hi,

Is there a way to do something like :

```julia
using StaticArrays
f(x) = "This is the fallback generic function"
f(x::MVector{M,T}) where {T,M<=10} = "You passed a MVector with less than 10 ellements"

```

?

I have the following error :

```julia
julia> f(x::MVector{M,T}) where {T,M<=10} = "You passed a MVector with less than 10 ellements"
ERROR: syntax: invalid variable expression in "where" around REPL[26]:1
Stacktrace:
 [1] top-level scope
   @ REPL[26]:1

julia> 

```

---

<div class="post-metadata">

**Author:** ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)\
**Post date:** [January 15, 2022, 9:12pm UTC](https://discourse.julialang.org/t/dispatch-on-size-of-mvectors/74685/2 "2022-01-15T21:12:44Z")

</div>

you can’t do computation within type parameters, Julia does NOT have dependent types; here’s a hack:

```julia
julia> for M = 0:10
           @eval f(x::MVector{$M,T}) where {T} = "less than 10"
       end

julia> f(@MVector [1,2,3,4,5,6,7,8,9,10,11])
"This is the fallback generic function"

julia> f(@MVector [1,2,3,4,5,6,7,8,9])
"less than 10"

```
