# Reference to two vectors?

**URL:** <https://discourse.julialang.org/t/reference-to-two-vectors/42024>\
**Category:** New to Julia\
**Created:** [June 25, 2020, 4:44am UTC](https://discourse.julialang.org/t/reference-to-two-vectors/42024 "2020-06-25T04:44:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomtom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomtom/32/5106_2.png) [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Post date:** [June 25, 2020, 4:44am UTC](https://discourse.julialang.org/t/reference-to-two-vectors/42024/1 "2020-06-25T04:44:03Z")

</div>

suppose I have two vectors:

```julia
a = [1, 2];
b = [3, 4]

```

how could I create a **single** “reference” vector `c`, which is a concatenation of `a` and `b`, so that any changes in each would be reflected in the others??

for example, below is a **failed** attempt:

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

julia> a[1] = 10
10

julia> c
4-element Array{Int64,1}:
 1
 2
 3
 4

```

here `c` is a concrete vector rather than a reference, hence any changes in `a` is not able to see in `c`.

please help

---

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [June 25, 2020, 4:52am UTC](https://discourse.julialang.org/t/reference-to-two-vectors/42024/2 "2020-06-25T04:52:57Z")

</div>

Not sure how to do what you asked for, but can you go the other way?

```julia
c = [1,2,3,4]
a = view(c, 1:2)
b = view(c, 3:4)

```

```julia
a[1] = 10
b[1] = 11

```

```julia
julia> c
4-element Array{Int64,1}:
 10
  2
 11
  4

```

---

<div class="post-metadata">

**Author:** ![tomtom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomtom/32/5106_2.png) [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Post date:** [June 25, 2020, 4:54am UTC](https://discourse.julialang.org/t/reference-to-two-vectors/42024/3 "2020-06-25T04:54:05Z")

</div>

OH!!! I’m just too stupid and rigid to overlook this solution 🤪 thanks.

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [June 25, 2020, 5:24am UTC](https://discourse.julialang.org/t/reference-to-two-vectors/42024/4 "2020-06-25T05:24:57Z")

</div>

That’s a good solution. There’s also [https://github.com/ahwillia/CatViews.jl](https://github.com/ahwillia/CatViews.jl)
