Broadcasting and arrays of arrays

Your other options all work, but are going to re-compute mean(d) for every element.

I’m also super surprised by the behavior of Ref in this case, but I guess RefArrays behave differently in broadcast? In particular, it looks like a RefArray behaves like a scalar but only using the first element of the contained array. A 1-element tuple has the behavior I would expect, as does wrapping the array in a 1-element array.

julia> [1, 2] .- ([1, 2],)
2-element Array{Array{Int64,1},1}:
 [0, -1]
 [1, 0] 

julia> [1, 2] .- Ref([1, 2])  # behaves like [1, 2] .- [1]
2-element Array{Int64,1}:
 0
 1

julia> [1, 2] .- [[1, 2]]
2-element Array{Array{Int64,1},1}:
 [0, -1]
 [1, 0] 

this is surprising enough that I might consider it a broadcast bug.