replaceInto

Replace occurrences of from with to in subject and output the result into sink.

void
replaceInto
(
E
Sink
R1
R2
)
(
Sink sink
,,
R1 from
,
R2 to
)
if (
isOutputRange!(Sink, E) &&
(
is(Unqual!E : Unqual!R1)
)
)

Parameters

sink Sink
subject E[]

the array to scan

from R1

the item to replace

to R2

the item to replace all instances of from with

Examples

auto arr = [1, 2, 3, 4, 5];
auto from = [2, 3];
auto to = [4, 6];
auto sink = appender!(int[])();

replaceInto(sink, arr, from, to);

assert(sink.data == [1, 4, 6, 4, 5]);

See Also

Meta

Suggestion Box / Bug Report