Why is inplace addition to array slice allocating?

I think it is because

foo[1,:,1] .+= 2

expands to

foo[1,:,1] .= foo[1,:,1] .+ 2

so a copy of the slice is assigned.
see: Allocation when assigning to a slice

2 Likes