# Not able to understand why everything is Vector or Matrix types which are alias types of Array

**URL:** <https://discourse.julialang.org/t/not-able-to-understand-why-everything-is-vector-or-matrix-types-which-are-alias-types-of-array/102902>\
**Category:** General Usage\
**Tags:** question\
**Created:** [August 17, 2023, 12:34pm UTC](https://discourse.julialang.org/t/not-able-to-understand-why-everything-is-vector-or-matrix-types-which-are-alias-types-of-array/102902 "2023-08-17T12:34:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![saampandit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/saampandit/32/52335_2.png) [@saampandit](https://discourse.julialang.org/u/saampandit)\
**Post date:** [August 17, 2023, 12:34pm UTC](https://discourse.julialang.org/t/not-able-to-understand-why-everything-is-vector-or-matrix-types-which-are-alias-types-of-array/102902/1 "2023-08-17T12:34:58Z")

</div>

How we should create an object whose type is Array not Vector or Matrix which are aliases of Arrays

For example if I can create an Array

```plaintext
x = ["random", 1, "test", 3.1455]
y = ["Hello" 1 ; "test" "random"]

```

then typeof output for

```plaintext
typeof(x)
typeof(y)

```

Results in  
Vector{Any} (alias for Array{Any, 1})  
Matrix{Any} (alias for Array{Any, 2})

---

<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:** [August 17, 2023, 12:50pm UTC](https://discourse.julialang.org/t/not-able-to-understand-why-everything-is-vector-or-matrix-types-which-are-alias-types-of-array/102902/2 "2023-08-17T12:50:00Z")

</div>

What is the problem with one- and two-dimensional `Array` types having shorter equivalent names?

Anyway, if you absolutely want to create an object of an `Array` type which doesn’t happen to have a shorter alias, you can do

```julia
julia> z = ["Hello" ;;; 1]
1×1×2 Array{Any, 3}:
[:, :, 1] =
 "Hello"

[:, :, 2] =
 1

julia> typeof(z)
Array{Any, 3}

```

---

<div class="post-metadata">

**Author:** ![saampandit](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/saampandit/32/52335_2.png) [@saampandit](https://discourse.julialang.org/u/saampandit)\
**Post date:** [August 17, 2023, 1:18pm UTC](https://discourse.julialang.org/t/not-able-to-understand-why-everything-is-vector-or-matrix-types-which-are-alias-types-of-array/102902/3 "2023-08-17T13:18:55Z")

</div>

Thanks, this is slightly confusing when coming from Python, I am checking when we have Vector, Matrices and Arrays

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 17, 2023, 1:33pm UTC](https://discourse.julialang.org/t/not-able-to-understand-why-everything-is-vector-or-matrix-types-which-are-alias-types-of-array/102902/4 "2023-08-17T13:33:35Z")

</div>

> [@saampandit](#):
>
> I am checking when we have Vector, Matrices and Arrays

They are all the same thing. `Vector` is a synonym for a 1d `Array` and `Matrix` is a synonym for a 2d `Array`. The short names are just to make it easier to type and talk about.

---

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [August 17, 2023, 2:54pm UTC](https://discourse.julialang.org/t/not-able-to-understand-why-everything-is-vector-or-matrix-types-which-are-alias-types-of-array/102902/5 "2023-08-17T14:54:04Z")

</div>

Just to make this abundantly clear, `Vector{T}` is a type alias (see the docs [here](https://docs.julialang.org/en/v1/manual/types/#Type-Aliases) and [here](https://docs.julialang.org/en/v1/manual/types/#UnionAll-Types)) for `Array{T,1}`, and `Matrix{T}` is a type alias for `Array{T,2}`. Type aliases are just new names for types that are exactly equivalent to the old names:

```julia
julia> Vector{Int} === Array{Int,1}
true

julia> Matrix{Int} === Array{Int,2}
true

```

You can even define your own type aliases using regular assignment (usually to a `const` variable):

```julia
julia> struct LongName{S,T} end

julia> const LN = LongName{S,T} where {S,T};

julia> LN === LongName
true

julia> const LN2{S} = LongName{S,Int} where S
LN2 (alias for LongName{S, Int64} where S)

julia> LN2{String} === LongName{String, Int}
true

```

---

<div class="post-metadata">

**Author:** ![Nathan\_Boyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nathan_boyer/32/14825_2.png) [@Nathan\_Boyer](https://discourse.julialang.org/u/Nathan_Boyer)\
**Post date:** [August 17, 2023, 2:58pm UTC](https://discourse.julialang.org/t/not-able-to-understand-why-everything-is-vector-or-matrix-types-which-are-alias-types-of-array/102902/6 "2023-08-17T14:58:38Z")

</div>

`Array` (e.g. `Array{Any, 2}`) is the general name for a collection of some type (e.g. `Any`) across some number of dimensions (e.g. `2`). The most common number of dimensions are 1-dimensional arrays (also called vectors) and 2-dimensional arrays (also called matrices). We just don’t give special names to any of the arrays with dimensions larger than 2.

```julia
x = ["random", 1, "test", 3.1455] # 4-element Vector{Any}
y = ["Hello" 1 ; "test" "random"] # 2×2 Matrix{Any}
x isa Array # true
y isa Array # true
x isa Vector # true
y isa Vector # false
x isa Matrix # false
y isa Matrix # true
Vector{Any} === Array{Any, 1} # true
Matrix{Any} === Array{Any, 2} # true

```
