Chris Cain:

import std.algorithm : chain, map, copy;
import std.stdio;

void main() {
    ["Anders", "David", "James", "Jeff", "Joe", "Erik"]
        .map!(str => chain("Hello! ", str, "\n"))
        .copy(stdout.lockingTextWriter());
}


Will do it as well.

Right. forEach() has the advantage of being an unversal "sink".

Bye,
bearophile

Reply via email to