The OpenD Programming Language

replaceSlice

Creates a new array such that the items in slice are replaced with the items in replacement. slice and replacement do not need to be the same length. The result will grow or shrink based on the items given.

inout(T)[]
replaceSlice
(
T
)
(
inout(T)[] s
,
in T[] slice
,)

Parameters

s inout(T)[]

the base of the new array

slice T[]

the slice of s to be replaced

replacement T[]

the items to replace slice with

Return Value

Type: inout(T)[]

A new array that is s with slice replaced by replacement[].

Examples

auto a = [1, 2, 3, 4, 5];
auto b = replaceSlice(a, a[1 .. 4], [0, 0, 0]);

assert(b == [1, 0, 0, 0, 5]);

See Also

Meta