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
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