That is true. My code looks more like a C example, while yours is a nice, generic oneliner. And it is easy to turn it into an interator over the off-diagonal indices than allocating a new vector.
offdiag_iter(A) = (ι for ι in CartesianIndices(A) if ι[1] ≠ ι[2])
Thanks!