# How to check if all fields of a Tuple are the same

**URL:** <https://discourse.julialang.org/t/how-to-check-if-all-fields-of-a-tuple-are-the-same/32700>\
**Category:** General Usage\
**Created:** [December 25, 2019, 7:16pm UTC](https://discourse.julialang.org/t/how-to-check-if-all-fields-of-a-tuple-are-the-same/32700 "2019-12-25T19:16:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [December 25, 2019, 7:16pm UTC](https://discourse.julialang.org/t/how-to-check-if-all-fields-of-a-tuple-are-the-same/32700/1 "2019-12-25T19:16:01Z")

</div>

Let’s say you have

```julia
julia> t = ([1, 2], ["a", "b"])
([1, 2], ["a", "b"])

julia> typeof(t)
Tuple{Array{Int64,1},Array{String,1}}

```

Let’s say I have a function that takes in a tuple of abstract arrays, and I really need the elements in the tuple to be abstract arrays. However the tuple has unknown length, so you can’t just write

```julia

julia> t isa Tuple{<:AbstractArray, <:AbstractArray}
true

```

Ideally I would write

```julia
julia> t isa Tuple{<:AbstractArray...}

```

But that syntax isn’t supported.

Even if I can’t use dispatch to let Julia know the type of this variable at compile time, it would still be nice to throw an error using run-time information if the argument inputted doesn’t match the contract I want.

Thank you

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [December 25, 2019, 7:25pm UTC](https://discourse.julialang.org/t/how-to-check-if-all-fields-of-a-tuple-are-the-same/32700/2 "2019-12-25T19:25:52Z")

</div>

Maybe

```julia
t isa Tuple && all(t isa AbstractArray for t in t)

```

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [December 25, 2019, 7:41pm UTC](https://discourse.julialang.org/t/how-to-check-if-all-fields-of-a-tuple-are-the-same/32700/3 "2019-12-25T19:41:35Z")

</div>

Assume you actually want to check if all elements are `AbtractArray` and not “the same”.

```julia
t <: Tuple{Vararg{AbstractArray}}

```
