# Recovering MATLAB addict needs help to understand Julia indexing

**URL:** <https://discourse.julialang.org/t/recovering-matlab-addict-needs-help-to-understand-julia-indexing/56046>\
**Category:** General Usage\
**Tags:** makie\
**Created:** [February 25, 2021, 8:33pm UTC](https://discourse.julialang.org/t/recovering-matlab-addict-needs-help-to-understand-julia-indexing/56046 "2021-02-25T20:33:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![neuralian](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/neuralian/32/8859_2.png) [@neuralian](https://discourse.julialang.org/u/neuralian)\
**Post date:** [February 25, 2021, 8:33pm UTC](https://discourse.julialang.org/t/recovering-matlab-addict-needs-help-to-understand-julia-indexing/56046/1 "2021-02-25T20:33:00Z")

</div>

(In the REPL) Create a 1D array of 1D arrays of Points:

```julia
julia>using GLMakie
julia> A = fill(fill(Point2f0(0,0), 2), 2)
2-element Array{Array{Point{2,Float32},1},1}:
 [[0.0, 0.0], [0.0, 0.0]]
 [[0.0, 0.0], [0.0, 0.0]]

```

Change the value of the first point in the first vector of points:

```julia
julia> A[1][1] = Point2f0(1,1)
2-element Point{2,Float32} with indices SOneTo(2):
 1.0
 1.0

```

But …

```julia
julia> A
2-element Array{Array{Point{2,Float32},1},1}:
 [[1.0, 1.0], [0.0, 0.0]]
 [[1.0, 1.0], [0.0, 0.0]]

```

… why does this re-assign the first point in _every_ vector of points? I expect the result of the previous snippet to be

```julia
 [[1.0, 1.0], [0.0, 0.0]]
 [[0.0, 0.0], [0.0, 0.0]]

```

what am I missing???

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [February 25, 2021, 8:37pm UTC](https://discourse.julialang.org/t/recovering-matlab-addict-needs-help-to-understand-julia-indexing/56046/2 "2021-02-25T20:37:31Z")

</div>

`fill` puts _the same_ object in every slot of the array. Instead, you could use an array comprehension to _create a new object_ for each slot:

```julia
[[Point2f0(0,0) for _ in 1:2] for _ in 1:2]

```
