Is std.array.replace supposed to work with char[]?

bearophile bearophileHUGS at lycos.com
Sun Feb 20 14:50:27 PST 2011


Steven Schveighoffer:

> Just a blind guess, I have not tested, but maybe it's because the compiler  
> is using const(char) as the return type for your delegate literal since  
> you never specify one?

Right, this works:

import std.stdio, std.random, std.string, std.algorithm, std.range;
void main() {
    string s = array(map!((i){ return cast(char)("AB"[uniform(0,2)]); })(iota(10))).idup;
    writeln(s);
}

Thank you, bye,
bearophile


More information about the Digitalmars-d-learn mailing list