# Extract ... from Tuple{...} and verify fixed length

**URL:** https://discourse.julialang.org/t/extract-from-tuple-and-verify-fixed-length/6308
**Category:** General Usage
**Tags:** question
**Created:** [October 7, 2017, 12:05pm UTC](https://discourse.julialang.org/t/extract-from-tuple-and-verify-fixed-length/6308 "2017-10-07T12:05:11Z")
**Posts on this page:** 2
**Page:** 1

<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: [October 7, 2017, 12:05pm UTC](https://discourse.julialang.org/t/extract-from-tuple-and-verify-fixed-length/6308/1 "2017-10-07T12:05:11Z")

</div>

What is the canonical way of extracting the parameters of a `Tuple`, and verifying that it has fixed length? Using advice I got in [another topic](https://discourse.julialang.org/t/what-are-valid-type-parameters/471), I am now using

```julia
"""
    extract_Tuple_fixed(T)

Extract the parameters of a Tuple and verify that they have a fixed length.
"""
function extract_Tuple_fixed(T::Type{<: Tuple})
    p = tuple(T.parameters...)
    @assert !(p[end] <: Vararg) "Not a tuple of fixed length."
    p
end

```

which works:

```julia
julia> extract_Tuple_fixed(Tuple{Int,Int})
(Int64, Int64)

julia> extract_Tuple_fixed(NTuple{4,Int})
(Int64, Int64, Int64, Int64)

julia> extract_Tuple_fixed(Tuple{Int,Vararg{Int}})
ERROR: AssertionError: Not a tuple of fixed length.
Stacktrace:
 [1] extract_Tuple_fixed(::Type{Tuple{Int64,Vararg{Int64,N} where N}}) at ./REPL[83
]:3                                                                               

```

but I am wondering if there is something neater, eg with a parametric function-template

```julia
this_does_not_work(::Type{Tuple{T...}}) = T

```

---

<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: [October 24, 2017, 2:25pm UTC](https://discourse.julialang.org/t/extract-from-tuple-and-verify-fixed-length/6308/2 "2017-10-24T14:25:30Z")

</div>

Update: `Base.isvatuple` can do the test. `T.parameters` still looks like the best way to extract the type parameters.
