# Why doesn't modifying a shallow copy of an array reflect on the original?

**URL:** <https://discourse.julialang.org/t/why-doesnt-modifying-a-shallow-copy-of-an-array-reflect-on-the-original/48445>\
**Category:** New to Julia\
**Created:** [October 15, 2020, 5:44pm UTC](https://discourse.julialang.org/t/why-doesnt-modifying-a-shallow-copy-of-an-array-reflect-on-the-original/48445 "2020-10-15T17:44:01Z")\
**Posts on this page:** 1\
**Showing post:** 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:** [October 15, 2020, 5:58pm UTC](https://discourse.julialang.org/t/why-doesnt-modifying-a-shallow-copy-of-an-array-reflect-on-the-original/48445/2 "2020-10-15T17:58:49Z")

</div>

Because even a shallow copy has to mean something other than just adding a reference to the same object. The behavior you expect you would get from doing

```julia
b = even_numbers

```

This is a better example of a shallow copy:

```julia
julia> a = [[1, 2], [3, 4]]
2-element Array{Array{Int64,1},1}:
 [1, 2]
 [3, 4]

julia> b = copy(a)
2-element Array{Array{Int64,1},1}:
 [1, 2]
 [3, 4]

julia> push!(b[1], 5)
3-element Array{Int64,1}:
 1
 2
 5

julia> a
2-element Array{Array{Int64,1},1}:
 [1, 2, 5]
 [3, 4]

julia> b
2-element Array{Array{Int64,1},1}:
 [1, 2, 5]
 [3, 4]

```

---

_[View the full topic](https://discourse.julialang.org/t/why-doesnt-modifying-a-shallow-copy-of-an-array-reflect-on-the-original/48445)._
