# Increment some components of a vector

**URL:** <https://discourse.julialang.org/t/increment-some-components-of-a-vector/53769>\
**Category:** New to Julia\
**Created:** [January 22, 2021, 8:45am UTC](https://discourse.julialang.org/t/increment-some-components-of-a-vector/53769 "2021-01-22T08:45:11Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Benoit\_Gaudeul](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/benoit_gaudeul/32/21256_2.png) [@Benoit\_Gaudeul](https://discourse.julialang.org/u/Benoit_Gaudeul)\
**Post date:** [January 22, 2021, 9:07am UTC](https://discourse.julialang.org/t/increment-some-components-of-a-vector/53769/4 "2021-01-22T09:07:41Z")

</div>

Thanks a lot for your replies, both ways seem great, and I’m glad to discover this `@view` functionality.

> [@Could you explain what are views?](https://discourse.julialang.org/t/could-you-explain-what-are-views/17535/2):
>
> Try and modify the result, and you’ll see the difference: julia\> A = [1 2; 3 4]; julia\> B = A[:,:]; # This is actually a copy of A julia\> B[1,1]=0; julia\> A 2×2 Array{Int64,2}: 1 2 3 4 julia\> B 2×2 Array{Int64,2}: 0 2 3 4 But: julia\> B = @view A[:,:]; # B is a view of A julia\> B[1,1]=0; julia\> A # Ooops! 2×2 Array{Int64,2}: 0 2 3 4 julia\> B 2×2 view(::Array{Int64,2}, :, slight_smile with eltype Int64: 0 2 3 4 In this particular case, it’s the same as B = A, so @view does not se…

---

_[View the full topic](https://discourse.julialang.org/t/increment-some-components-of-a-vector/53769)._
