import mir.ndslice.allocation; auto a = slice!int(2, 3); a[] = 9; assert(a == [[9, 9, 9], [9, 9, 9]]); a[0..$, 0..$-1] = 1; assert(a == [[1, 1, 9], [1, 1, 9]]); a[0..$, 0..$-1] = 2; assert(a == [[2, 2, 9], [2, 2, 9]]); a[1, 0..$-1] = 3; //assert(a[1] == [3, 3, 9]); a[1, 0..$-1] = 4; //assert(a[1] == [4, 4, 9]); a[1, 0..$-1][] = 5; assert(a[1] == [5, 5, 9]);
Packed slices have the same behavior.
import mir.ndslice.allocation; import mir.ndslice.topology : pack; auto a = slice!int(2, 3).pack!1; a[] = 9; //assert(a == [[9, 9, 9], [9, 9, 9]]);