# Customizing Broadcasting Recursively for Collections of Arrays

**URL:** <https://discourse.julialang.org/t/customizing-broadcasting-recursively-for-collections-of-arrays/25724>\
**Category:** General Usage\
**Created:** [June 26, 2019, 2:41pm UTC](https://discourse.julialang.org/t/customizing-broadcasting-recursively-for-collections-of-arrays/25724 "2019-06-26T14:41:17Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [June 26, 2019, 2:54pm UTC](https://discourse.julialang.org/t/customizing-broadcasting-recursively-for-collections-of-arrays/25724/2 "2019-06-26T14:54:30Z")

</div>

Extending upon your previous solution, you’ll need to now implement broadcasting for your style. You do this by implementing `copyto!(dest::A, bc::Broadcast.Broadcasted{MyStyle})`. There are two challenges here:

1. Implementing that method isn’t easy. You need to support any arbitrary combinations of fused expressions and do the indexing computations yourself — you can make this a bit easier (at the sacrifice of a bit of performance) by using `Broadcast.flatten`, which transforms the nested expression tree into a single function and a flat list of arguments. It’s still hard and annoying.

2. Perhaps more importantly, you’re at the edge of (or possibly beyond) supported broadcasting use-cases. Broadcast is defined as doing an element-wise computation, but what is an “element” of `A`? See [Broadcasting in 0.7](https://discourse.julialang.org/t/broadcasting-in-0-7/12346/1) and [https://github.com/JuliaLang/julia/issues/27988#issuecomment-403319535](https://github.com/JuliaLang/julia/issues/27988#issuecomment-403319535) for more details.

---

_[View the full topic](https://discourse.julialang.org/t/customizing-broadcasting-recursively-for-collections-of-arrays/25724)._
