The OpenD Programming Language

replaceInto

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

  1. void replaceInto(Sink sink, E[] subject, R1 from, R2 to)
    void
    replaceInto
    (
    E
    Sink
    R1
    R2
    )
    (
    Sink sink
    ,,
    R1 from
    ,
    R2 to
    )
    if (
    isOutputRange!(Sink, E) &&
    (
    is(Unqual!E : Unqual!R1)
    )
    )
  2. void replaceInto(Sink sink, E[] subject, R1 from, R2 to, size_t changed)

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