# How does push!() work within accumulate()?

**URL:** https://discourse.julialang.org/t/how-does-push-work-within-accumulate/81286
**Category:** General Usage
**Tags:** accumulate, push
**Created:** [May 18, 2022, 10:01pm UTC](https://discourse.julialang.org/t/how-does-push-work-within-accumulate/81286 "2022-05-18T22:01:40Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![rdeits](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rdeits/32/286_2.png) [@rdeits](https://discourse.julialang.org/u/rdeits)
#### Post date: [May 18, 2022, 11:32pm UTC](https://discourse.julialang.org/t/how-does-push-work-within-accumulate/81286/2 "2022-05-18T23:32:58Z")

</div>

`push!` mutates a vector, while concatenation with `[s; c]` creates a completely new vector. In the first case, you’re mutating that same initial vector `[]` over and over, so each element in the result is the _same_ vector and has the same value. In the second case, you’re creating a brand new vector with `[s; c]` at each iteration, so the accumulated results aren’t all identical.

---

_[View the full topic](https://discourse.julialang.org/t/how-does-push-work-within-accumulate/81286)._
