# Usage of keyword \`const\` in the context of types. (code from Julia documentation)

**URL:** <https://discourse.julialang.org/t/usage-of-keyword-const-in-the-context-of-types-code-from-julia-documentation/32654>\
**Category:** New to Julia\
**Created:** [December 24, 2019, 2:43pm UTC](https://discourse.julialang.org/t/usage-of-keyword-const-in-the-context-of-types-code-from-julia-documentation/32654 "2019-12-24T14:43:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![reumle](https://avatars.discourse-cdn.com/v4/letter/r/5daacb/32.png) [@reumle](https://discourse.julialang.org/u/reumle)\
**Post date:** [December 24, 2019, 2:43pm UTC](https://discourse.julialang.org/t/usage-of-keyword-const-in-the-context-of-types-code-from-julia-documentation/32654/1 "2019-12-24T14:43:14Z")

</div>

Hi, I read this in Julia doc ([Types · The Julia Language](https://docs.julialang.org/en/v1/manual/types/#UnionAll-Types-1))

```julia
julia> const T1 = Array{Array{T,1} where T, 1}
Array{Array{T,1} where T,1}

```

1. What is the meaning of `const` in this context?
  - eg I built a variable like here below, and it is not very constant?

```julia
julia> aa=T1([[2.0],[6::Int64],["bof"]])
3-element Array{Array{T,1} where T,1}:
 [2.0]
 [6]
 ["bof"]
julia> aa[2]=[1];

julia> aa
3-element Array{Array{T,1} where T,1}:
 [2.0]
 [1]
 ["bof"]

```

I also tried this (without the `const`) like this: `T2 = Array{Array{T,1} where T, 1} ` the difference with `T1` is not clear to me.

1. Where is the documentation for this use of `const` (ie in a type declaration context)?

Thank you!

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [December 24, 2019, 4:54pm UTC](https://discourse.julialang.org/t/usage-of-keyword-const-in-the-context-of-types-code-from-julia-documentation/32654/2 "2019-12-24T16:54:13Z")

</div>

`const` does not have any special meaning here.

This is not a “type declaring syntax” and merely an assignment of a type to a constant variable. In another word, the only difference between `T1` and `T2` is that you can assign to `T2` but not to `T1`

---

<div class="post-metadata">

**Author:** ![cshen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cshen/32/217287_2.png) [@cshen](https://discourse.julialang.org/u/cshen)\
**Post date:** [December 24, 2019, 4:58pm UTC](https://discourse.julialang.org/t/usage-of-keyword-const-in-the-context-of-types-code-from-julia-documentation/32654/3 "2019-12-24T16:58:30Z")

</div>

To build on yuyichao reply.  
You basically renamed that particular type with `T1`, and reserved the name `T1` for that particular use.

you declared `T1` to be `const`, not `aa`, that is why you can manipulate the entries of `aa`.

---

<div class="post-metadata">

**Author:** ![reumle](https://avatars.discourse-cdn.com/v4/letter/r/5daacb/32.png) [@reumle](https://discourse.julialang.org/u/reumle)\
**Post date:** [December 25, 2019, 4:43pm UTC](https://discourse.julialang.org/t/usage-of-keyword-const-in-the-context-of-types-code-from-julia-documentation/32654/4 "2019-12-25T16:43:26Z")

</div>

Thank you both!

---

<div class="post-metadata">

**Author:** ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)\
**Post date:** [December 25, 2019, 7:42pm UTC](https://discourse.julialang.org/t/usage-of-keyword-const-in-the-context-of-types-code-from-julia-documentation/32654/5 "2019-12-25T19:42:26Z")

</div>

> [@cshen](#):
>
> you declared `T1` to be `const` , not `aa` , that is why you can manipulate the entries of `aa` .

There’s nothing you can do by adding `const` to make `aa` immutable.
