# An object which is Tuple, but not an NTuple{N, Any}

**URL:** <https://discourse.julialang.org/t/an-object-which-is-tuple-but-not-an-ntuple-n-any/36426>\
**Category:** New to Julia\
**Tags:** question\
**Created:** [March 24, 2020, 10:13am UTC](https://discourse.julialang.org/t/an-object-which-is-tuple-but-not-an-ntuple-n-any/36426 "2020-03-24T10:13:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ravi.joshi](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@ravi.joshi](https://discourse.julialang.org/u/ravi.joshi)\
**Post date:** [March 24, 2020, 10:13am UTC](https://discourse.julialang.org/t/an-object-which-is-tuple-but-not-an-ntuple-n-any/36426/1 "2020-03-24T10:13:43Z")

</div>

In Julia, is it possible to have an object, which is a Tuple, but not an NTuple{N, Any}?  
I am thinking about this because, in the Iterators module, there are different method dispatches for NTuple and Tuple object for the function flatten\_iteratorsize.

> **[Code coverage done right.](https://app.codecov.io/gh/julialang/julia/blob/master/base/iterators.jl)**
>
> Hosted coverage report highly integrated with GitHub, Bitbucket and GitLab. Awesome pull request comments to enhance your QA.

From what I understand, NTuple{N, Any} and Tuple are just aliases. Am I correct?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 24, 2020, 10:19am UTC](https://discourse.julialang.org/t/an-object-which-is-tuple-but-not-an-ntuple-n-any/36426/2 "2020-03-24T10:19:58Z")

</div>

while

```julia
julia> (NTuple{N,Any} where N) == Tuple
true

```

what you are seeing for [`flatten_iteratorsize`](https://github.com/JuliaLang/julia/blob/ee3be105eb13754cd63a256ce011033909f53cb5/base/iterators.jl#L1031) is dispatching on _types_, where the distinction of having a `Tuple` type (which can have any length) or an `NTuple` with a given length (which is used) is meaningful.

---

<div class="post-metadata">

**Author:** ![ravi.joshi](https://avatars.discourse-cdn.com/v4/letter/r/90ced4/32.png) [@ravi.joshi](https://discourse.julialang.org/u/ravi.joshi)\
**Post date:** [March 24, 2020, 10:28am UTC](https://discourse.julialang.org/t/an-object-which-is-tuple-but-not-an-ntuple-n-any/36426/3 "2020-03-24T10:28:06Z")

</div>

That’s true, but doesn’t taking length N as a generic parameter in the method make NTuple{N, Any} type same as Tuple?  
I am not able to think of an example where the method with the NTuple dispatch will not be called (i.e. the one with Tuple dispatch be called). Can you please give such an example?

---

<div class="post-metadata">

**Author:** ![Tamas\_Papp](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tamas_papp/32/25949_2.png) [@Tamas\_Papp](https://discourse.julialang.org/u/Tamas_Papp)\
**Post date:** [March 24, 2020, 11:01am UTC](https://discourse.julialang.org/t/an-object-which-is-tuple-but-not-an-ntuple-n-any/36426/4 "2020-03-24T11:01:02Z")

</div>

```julia
foo(::Type{<:Tuple}) = "I am some generic tuple type"
foo(::Type{<:NTuple{N,Any}}) where N = "I know my length, and it is $N"
foo(Tuple) # will call first method
foo(Tuple{Int,Float64}) # will call second method

```
