# Can I alias an array element to a simple name like \`x\`?

**URL:** <https://discourse.julialang.org/t/can-i-alias-an-array-element-to-a-simple-name-like-x/45337>\
**Category:** General Usage\
**Created:** [August 21, 2020, 8:32pm UTC](https://discourse.julialang.org/t/can-i-alias-an-array-element-to-a-simple-name-like-x/45337 "2020-08-21T20:32:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![NightMachinary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nightmachinary/32/14196_2.png) [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Post date:** [August 21, 2020, 8:32pm UTC](https://discourse.julialang.org/t/can-i-alias-an-array-element-to-a-simple-name-like-x/45337/1 "2020-08-21T20:32:35Z")

</div>

I want to alias some array elements to simple variable names for readability:

```julia
a = collect(700:710)
alias b = a[10] # pseudocode
alias c = a[20]
b = 6
@assert a[10] == 6

```

How can I do this? The aliases can be only in the current scope so as not to introduce GC problems.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [August 21, 2020, 8:50pm UTC](https://discourse.julialang.org/t/can-i-alias-an-array-element-to-a-simple-name-like-x/45337/2 "2020-08-21T20:50:50Z")

</div>

You can use single-element `view`s:

```julia
julia> a = collect(700:710);

julia> b = @view a[10]
0-dimensional view(::Array{Int64,1}, 10) with eltype Int64:
709

julia> b .= 6
0-dimensional view(::Array{Int64,1}, 10) with eltype Int64:
6

julia> a[10]
6

```

---

<div class="post-metadata">

**Author:** ![NightMachinary](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nightmachinary/32/14196_2.png) [@NightMachinary](https://discourse.julialang.org/u/NightMachinary)\
**Post date:** [August 21, 2020, 8:53pm UTC](https://discourse.julialang.org/t/can-i-alias-an-array-element-to-a-simple-name-like-x/45337/3 "2020-08-21T20:53:58Z")

</div>

> [@fredrikekre](#):
>
> `a = collect(700:710);`

`b[] = 13 # assignment`

Thanks.
