# Broadcasting across a nested array

**URL:** <https://discourse.julialang.org/t/broadcasting-across-a-nested-array/21700>\
**Category:** General Usage\
**Tags:** broadcasting\
**Created:** [March 10, 2019, 12:21pm UTC](https://discourse.julialang.org/t/broadcasting-across-a-nested-array/21700 "2019-03-10T12:21:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![ffevotte](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffevotte/32/6587_2.png) [@ffevotte](https://discourse.julialang.org/u/ffevotte)\
**Post date:** [March 10, 2019, 12:26pm UTC](https://discourse.julialang.org/t/broadcasting-across-a-nested-array/21700/2 "2019-03-10T12:26:42Z")

</div>

Try wrapping the first operand in a `Ref` to help Julia understand it is a “scalar”:

```julia
julia> Ref([10, 100]) .+ [[5, 5], [6, 6], [7, 7]]
 3-element Array{Array{Int64,1},1}:
  [15, 105]
  [16, 106]
  [17, 107]

```

  

* * *

This discussion contains a lot more details:

> [@recent broadcast changes (iterate by default), scalar struct, and \`@.\`](https://discourse.julialang.org/t/recent-broadcast-changes-iterate-by-default-scalar-struct-and/11178):
>
> The current broadcasting behavior is non-intuitive when used with @. Julia Version 0.7.0-DEV.5222, Commit 7144b6b816 (2018-05-25 20:23 UTC) This is a minimal example, stripped down from a real use case. struct Material a::Float64 end chi(m::Material, energy) = m.a / energy m1 = Material(1.0) energy = 1.5:0.5:2.5 chi1 = @. chi(m1, energy) ┌ Warning: broadcast will default to iterating over its arguments in the future. Wrap arguments of │ type `x::Material` with `Ref(x)` to ensure they b…

including some alternative ways of doing this, for example turning the “scalar” argument to a 1-Tuple:

```julia
julia> ([10, 100],) .+ [[5, 5], [6, 6], [7, 7]]
3-element Array{Array{Int64,1},1}:
 [15, 105]
 [16, 106]
 [17, 107]

```

---

_[View the full topic](https://discourse.julialang.org/t/broadcasting-across-a-nested-array/21700)._
