# Subtypes of \`Vector{NamedTuple}\`

**URL:** <https://discourse.julialang.org/t/subtypes-of-vector-namedtuple/21285>\
**Category:** New to Julia\
**Created:** [February 28, 2019, 2:18am UTC](https://discourse.julialang.org/t/subtypes-of-vector-namedtuple/21285 "2019-02-28T02:18:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![robsmith11](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robsmith11/32/29641_2.png) [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Post date:** [February 28, 2019, 2:18am UTC](https://discourse.julialang.org/t/subtypes-of-vector-namedtuple/21285/1 "2019-02-28T02:18:05Z")

</div>

I’m trying to write a function that handles vectors of `NamedTuple`s differently than vectors of other types, but I can’t get it to dispatch properly.

It seems that there is a problem detecting subtypes of `Vector{NamedTuple}`. For example, I would expect the following to be true:

```julia
julia> typeof([(x=1,)]) <: Vector{NamedTuple}
false

```

Why doesn’t that work?

Without the `Vector`, it works fine:

```julia
julia> typeof((x=1,)) <: NamedTuple
true

```

---

<div class="post-metadata">

**Author:** ![robsmith11](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/robsmith11/32/29641_2.png) [@robsmith11](https://discourse.julialang.org/u/robsmith11)\
**Post date:** [February 28, 2019, 2:33am UTC](https://discourse.julialang.org/t/subtypes-of-vector-namedtuple/21285/2 "2019-02-28T02:33:35Z")

</div>

Ah… I found the documentation regarding “invariant” types.

The solution to my problem is to write `f(x::Vector{<:NamedTuple})` rather than `f(x::Vector{NamedTuple})`.
