# Why is it not matching NTuple{N,T} when specifying N

**URL:** <https://discourse.julialang.org/t/why-is-it-not-matching-ntuple-n-t-when-specifying-n/13382>\
**Category:** General Usage\
**Tags:** question, ntuple\
**Created:** [August 13, 2018, 2:57pm UTC](https://discourse.julialang.org/t/why-is-it-not-matching-ntuple-n-t-when-specifying-n/13382 "2018-08-13T14:57:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shipengcheng1230](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/shipengcheng1230/32/4089_2.png) [@shipengcheng1230](https://discourse.julialang.org/u/shipengcheng1230)\
**Post date:** [August 13, 2018, 2:57pm UTC](https://discourse.julialang.org/t/why-is-it-not-matching-ntuple-n-t-when-specifying-n/13382/1 "2018-08-13T14:57:26Z")

</div>

Consider the following code:

```julia
julia> f1(x::NTuple{N,T}) where {N, T<:Number} = "ok"
f1 (generic function with 1 method)

julia> f1((1,2,3))
"ok"

```

However, when I specifying `N` to be an integer as following:

```julia
julia> f2(x::NTuple{N,T}) where {N<:Integer, T<:Number} = "not work"
f2 (generic function with 1 method)

julia> f2((1,2,3))
ERROR: MethodError: no method matching f2(::Tuple{Int64,Int64,Int64})
Closest candidates are:
  f2(::Tuple{Vararg{T<:Number,N<:Integer}}) where {N<:Integer, T<:Number} at REPL[3]:1
Stacktrace:
 [1] top-level scope at none:0

```

Why would `Tuple{Int64,Int64,Int64}` not match `NTuple{N,T} where {N<:Integer, T<:Number}` here?

---

<div class="post-metadata">

**Author:** ![jebej](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jebej/32/1784_2.png) [@jebej](https://discourse.julialang.org/u/jebej)\
**Post date:** [August 13, 2018, 3:01pm UTC](https://discourse.julialang.org/t/why-is-it-not-matching-ntuple-n-t-when-specifying-n/13382/2 "2018-08-13T15:01:32Z")

</div>

When you specify `N<:Integer`, what you are actually telling Julia is not “N is an `Integer`”, instead you are saying, “N is a _type_ which is a subtype of `Integer`”. However, you do not want `N` to be a type, but a number. There is currently no way to specify this: [https://github.com/JuliaLang/julia/issues/9580](https://github.com/JuliaLang/julia/issues/9580).

---

<div class="post-metadata">

**Author:** ![jebej](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jebej/32/1784_2.png) [@jebej](https://discourse.julialang.org/u/jebej)\
**Post date:** [August 13, 2018, 3:03pm UTC](https://discourse.julialang.org/t/why-is-it-not-matching-ntuple-n-t-when-specifying-n/13382/3 "2018-08-13T15:03:37Z")

</div>

To illustrate the difference a bit more, note that if this was ever allowed, the notation would probably be something like this: (`::` vs. `<:`)

```julia
f2(x::NTuple{N,T}) where {N::Integer, T<:Number}

```
