# Array{T, 1} where T\<:Real versus Array{T where T\<:Real, 1}

**URL:** https://discourse.julialang.org/t/array-t-1-where-t-real-versus-array-t-where-t-real-1/31249
**Category:** General Usage
**Tags:** question
**Created:** [November 19, 2019, 5:20am UTC](https://discourse.julialang.org/t/array-t-1-where-t-real-versus-array-t-where-t-real-1/31249 "2019-11-19T05:20:13Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Sijun](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Sijun](https://discourse.julialang.org/u/Sijun)
#### Post date: [November 19, 2019, 5:20am UTC](https://discourse.julialang.org/t/array-t-1-where-t-real-versus-array-t-where-t-real-1/31249/1 "2019-11-19T05:20:13Z")

</div>

**`T1 = Array{T, 1} where T<:Real`** represents all possible arrays of the form **` [T, T, T, T, . . .]`**, i.e., any array of T1 consists of elements of the subtype of Real and they have to be of same type.

On the other hand, **`T2 = Array{T where T<:Real, 1}`** represents all possible arrays of the form **`[T, T', T'', T''', ...].`** So any array of T2 consists of elements of subtypes of Real but they could be of different types to each other.

Therefore I feel it is obvious that T2 can represent broader range of values than T1 can do. And if then, **`T1 <: T2`** should hold but actually the evaluation of **`T1 <: T2`** returns false.

Julia 1.2.0 manual explains that T2 is concrete type and T1 is abstract type, the fact of which can also be checked by trying T1() and T2() and maybe used as another justification of T2 \<: T1. But I really don’t understand why T1 is abstract while T2 is concrete.

Could any one help me clear my confusion?

Thanks!

---

<div class="post-metadata">

### Author: ![bashonubuntu](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@bashonubuntu](https://discourse.julialang.org/u/bashonubuntu)
#### Post date: [November 19, 2019, 5:50am UTC](https://discourse.julialang.org/t/array-t-1-where-t-real-versus-array-t-where-t-real-1/31249/2 "2019-11-19T05:50:51Z")

</div>

Hello,

If I’m not wrong, the link [Types · The Julia Language](https://docs.julialang.org/en/v1/manual/types/index.html) should help answer your query. To quote from the link, "even though `Float64 <: Real` we **do not** have `Point{Float64} <: Point{Real}`. For example,

```julia
julia> Float64 <: Real
true

julia> Array{Float64} <: Array{Real}
false

```

---

<div class="post-metadata">

### Author: ![Sijun](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Sijun](https://discourse.julialang.org/u/Sijun)
#### Post date: [November 19, 2019, 6:08am UTC](https://discourse.julialang.org/t/array-t-1-where-t-real-versus-array-t-where-t-real-1/31249/3 "2019-11-19T06:08:39Z")

</div>

@bashonubuntu, thanks for replying! 🙂

I see. So it looks like the answer to the question is closely related to type invariance. But specifically how the type invariance applies to this particular case (like math proof) is not crispy clear. Perhaps, I suppose full understanding requires learning type theory.

for the case of `Float64 <: Real`,` Array{Float64}` and `Array{Real}` are unrelated in the sense that `Array{Float64} <: Array{Real}` does not hold, nor does `Array{Real} <: Array{Float64}`. T1 and T2 above are related however: `T2 <: T1`.

---

<div class="post-metadata">

### Author: ![bashonubuntu](https://avatars.discourse-cdn.com/v4/letter/b/f19dbf/32.png) [@bashonubuntu](https://discourse.julialang.org/u/bashonubuntu)
#### Post date: [November 19, 2019, 6:16am UTC](https://discourse.julialang.org/t/array-t-1-where-t-real-versus-array-t-where-t-real-1/31249/4 "2019-11-19T06:16:06Z")

</div>

In your example, `T <: Real` but `Point{T} <: Point{Real}` is false. In your example, `Point` is basically `Array` which seems consistent with the link I shared above.

```julia
julia> T1 = Array{T} where T<:Real
Array{T,N} where N where T<:Real

julia> T2 = Array{T where T<:Real}
Array{Real,N} where N

julia> T1<:T2
false

```

---

<div class="post-metadata">

### Author: ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)
#### Post date: [November 19, 2019, 7:19am UTC](https://discourse.julialang.org/t/array-t-1-where-t-real-versus-array-t-where-t-real-1/31249/5 "2019-11-19T07:19:31Z")

</div>

Think about types in terms of sets, [see docs here](https://docs.julialang.org/en/v1/devdocs/types/#More-about-types-1).

`Vector{Int}, Vector{Float64}, Vector{Real}` are all members of the set of `T1`, but only `Vector{Real}` is a member of the set of `T2`. Thus `T1` is not a subset of `T2`, but `T2` is a subset of `T1`.

---

<div class="post-metadata">

### Author: ![Sijun](https://avatars.discourse-cdn.com/v4/letter/s/b2d939/32.png) [@Sijun](https://discourse.julialang.org/u/Sijun)
#### Post date: [November 19, 2019, 7:53am UTC](https://discourse.julialang.org/t/array-t-1-where-t-real-versus-array-t-where-t-real-1/31249/6 "2019-11-19T07:53:07Z")

</div>

Thanks @Mattriks, viewing in therms of sets is indeed much better approach! Let me ruminate for some more time for full digestion. 🙂 Perhaps I will be bringing some more queries on this later on…
