# Composite type comparison

**URL:** <https://discourse.julialang.org/t/composite-type-comparison/108192>\
**Category:** General Usage\
**Tags:** parametric-types\
**Created:** [December 30, 2023, 6:10pm UTC](https://discourse.julialang.org/t/composite-type-comparison/108192 "2023-12-30T18:10:22Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![purplishrock](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/purplishrock/32/13451_2.png) [@purplishrock](https://discourse.julialang.org/u/purplishrock)\
**Post date:** [December 30, 2023, 6:10pm UTC](https://discourse.julialang.org/t/composite-type-comparison/108192/1 "2023-12-30T18:10:22Z")

</div>

Something similar to this probably has been asked and answered before, but my search-Fu is not strong enough to find the answer.

I can’t figure out why the last comparison doesn’t succeed.

```julia
julia> x
([1], [1])

julia> typeof(x)
Tuple{Vector{Int64}, Vector{Int64}}

julia> typeof(x) <: Tuple
true

julia> typeof(x) <: Tuple{Vector, Vector}
true

julia> a
3-element Vector{Tuple{Vector{Int64}, Vector{Int64}}}:
 ([1], [1])
 ([1], [1])
 ([1], [1])

julia> typeof(a)
Vector{Tuple{Vector{Int64}, Vector{Int64}}} (alias for Array{Tuple{Array{Int64, 1}, Array{Int64, 1}}, 1})

julia> typeof(a) <: Vector
true

julia> typeof(a) <: Vector{Tuple}
false

```

I verified the “almost” full type, using Int but not Int64, does work.

```julia
julia> typeof(a) == Vector{Tuple{Vector{Int},Vector{Int}}}
true

```

Strangely, this doesn’t work…

```julia
julia> typeof(a) == Vector{Tuple{Vector{Number},Vector{Number}}}
false

```

even though

```julia
julia> Int64 <: Number
true

```

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://discourse.julialang.org/u/jules)\
**Post date:** [December 30, 2023, 7:20pm UTC](https://discourse.julialang.org/t/composite-type-comparison/108192/2 "2023-12-30T19:20:58Z")

</div>

Does this help?

> [@Why \[1, 2, 3\] is not a Vector{Number}?](https://discourse.julialang.org/t/why-1-2-3-is-not-a-vector-number/52645/3):
>
> Just to extract some relevant points because the manual is quite dense: Vector{Number} is a concrete type, and [1, 2, 3] has type Vector{Int}, which is also a concrete type. One concrete type is never a subtype of another concrete type, they are the leaves of the type tree. Vector{Number} is concrete, even though Number is not a concrete type. That’s because it has a concrete implementation which can store all types that are subtypes of Number, it has a specific memory layout etc. On the other…

In addition, the Tuple type is the only type which is covariant, which means that a Tuple is subtype of another Tuple if each of its element types is a subtype of the corresponding element type in the supertype Tuple.
