# Broadcasting over arrays of SVectors

**URL:** <https://discourse.julialang.org/t/broadcasting-over-arrays-of-svectors/57579>\
**Category:** New to Julia\
**Tags:** staticarrays\
**Created:** [March 20, 2021, 12:28am UTC](https://discourse.julialang.org/t/broadcasting-over-arrays-of-svectors/57579 "2021-03-20T00:28:30Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![lmiq](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lmiq/32/18314_2.png) [@lmiq](https://discourse.julialang.org/u/lmiq)\
**Post date:** [March 20, 2021, 5:07pm UTC](https://discourse.julialang.org/t/broadcasting-over-arrays-of-svectors/57579/18 "2021-03-20T17:07:48Z")

</div>

That admittedly is confusing at the beginning. One gets used to it, though, and after that one notes that actually there is no way out from that if one wants to have a dynamically typed language.

The fact that the language is dynamic requires that we can do

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

julia> x = π
π = 3.1415926535897...

```

That is completely natural, but means that `=` is just the binding of a name to a value (which might be an array, or scalar, or whatever).

Thus, we need to be able to differentiate naming something from mutating something. Mutating is a function that acts on a mutable object. It is the `setindex!` function:

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

julia> setindex!(x,10,1)
2-element Array{Int64,1}:
 10
  2

```

Which, by convenience (obviously) can be called with the notation:

```julia
julia> x[1] = 10
10

```

But this last `x[1] = 10` is a call to `setindex!`, not a name assignment as the other cases. (and a broadcasting of assignments, with `.=`, is just a loop calling `setindex!` for each element)

(ps, if you feel better, [here I am](https://discourse.julialang.org/t/copy-vector/20082) asking the same thing two years ago)

---

_[View the full topic](https://discourse.julialang.org/t/broadcasting-over-arrays-of-svectors/57579)._
