Problems with OutputRanges
Meta
jared771 at gmail.com
Mon Mar 24 19:42:55 PDT 2014
I'm not sure what I'm doing wrong... the following code prints
nothing:
void main()
{
import std.stdio, std.range;
string str = "asdf";
auto sink = new dchar[](str.length);
auto fun = (dchar c) { sink.put(c); };
foreach (dchar c; str)
{
fun(c);
}
writeln(sink);
}
If I print sink's length inside the foreach loop, its length is
reduced by 1 each step, until it's 0. That explains why nothing
is being printed, but why is put altering the length of the array?
More information about the Digitalmars-d-learn
mailing list