shift

Inserts at a given index in the slice while dropping its last element.

Basically a macro for

slice[index .. $].shiftRight(1);
slice[index] = x;
void
shift
(
T
)
(
T[] slice
,
size_t index
,
auto ref T x
)

Examples

static int[] a = [ 1, 2, 4, 5 ];
a.shift(2, 3);
assert(a[0] == 1); assert(a[1] == 2); assert(a[2] == 3); assert(a[3] == 4);