# Argument type for tuples of same length

**URL:** <https://discourse.julialang.org/t/argument-type-for-tuples-of-same-length/29174>\
**Category:** General Usage\
**Created:** [September 25, 2019, 8:04pm UTC](https://discourse.julialang.org/t/argument-type-for-tuples-of-same-length/29174 "2019-09-25T20:04:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wsshin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wsshin/32/360_2.png) [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Post date:** [September 25, 2019, 8:04pm UTC](https://discourse.julialang.org/t/argument-type-for-tuples-of-same-length/29174/1 "2019-09-25T20:04:55Z")

</div>

I would like to create a function taking two tuples `t1` and `t2` as arguments. The two tuples need to have the same length, but their elements can be of any type, and each tuple doesn’t need to be composed of the entries of the same type (i.e., the tuples can be inhomogeneous). An example satisfying this condition would be `t1 = (1, 1.0, true)` and `t2 = (zeros(3), "abc", 1//2)`.

Is it possible to specify the argument types enforcing this condition? I thought

```julia
function myfun(t1::NTuple{N}, t2::NTuple{N}) where {N}

```

would do the job, but it seems that `::NTuple` expects a homogeneous tuple (i.e., a tuple composed of entries of the same type).

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [September 25, 2019, 8:19pm UTC](https://discourse.julialang.org/t/argument-type-for-tuples-of-same-length/29174/2 "2019-09-25T20:19:30Z")

</div>

```julia
function myfun(t1::Tuple{Vararg{Any,N}}, t2::Tuple{Vararg{Any,N}}) where {N}

```

---

<div class="post-metadata">

**Author:** ![wsshin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wsshin/32/360_2.png) [@wsshin](https://discourse.julialang.org/u/wsshin)\
**Post date:** [September 25, 2019, 8:51pm UTC](https://discourse.julialang.org/t/argument-type-for-tuples-of-same-length/29174/3 "2019-09-25T20:51:35Z")

</div>

Thanks. I notice that

```julia
function myfun(t1::NTuple{N,Any}, t2::NTuple{N,Any}) where {N}

```

also works. But then this seems a bit strange for me. I thought the function signature in my original posting is equivalent to

```julia
function myfun(t1::NTuple{N,T}, t2::NTuple{N,S}) where {N,T,S}

```

but then it seems that Julia cannot infer that `T = Any` and `S = Any`. Am I missing something?
