How to determine when to broadcast

Sorry, that was my mistake, it is Indices which varies. Admittedly it is not perfect code, I’m building on a code base that I didn’t fully write.

So the example would be this:

I could have

A = [1,2,3]
X = 3
Indices = [2]

A[Indices...] = 3

I could also have

A = [1,2,3]
X = 3
Indices = [[2]]

A[Indices...] = 3

which will throw


julia> A[Indices...] = 3
ERROR: ArgumentError: indexed assignment with a single value to possibly many locations is not supported; perhaps use broadcasting `.=` instead?
Stacktrace:
 [1] setindex_shape_check(::Int64, ::Int64)
   @ Base ./indices.jl:261
 [2] _unsafe_setindex!(::IndexLinear, A::Vector{Int64}, x::Int64, I::Vector{Int64})
   @ Base ./multidimensional.jl:953
 [3] _setindex!
   @ Base ./multidimensional.jl:944 [inlined]
 [4] setindex!(A::Vector{Int64}, v::Int64, I::Vector{Int64})
   @ Base ./abstractarray.jl:1393
 [5] top-level scope
   @ REPL[18]:1