Passing sub-arrays by reference

a[1, :] always creates a new copy. If you actually want to pass a SubArray which still references the original array to a function, you should use view(a, 1, :) instead.

3 Likes