appender!(dchar[]) put fail
Dennis Ritchie via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sat Jun 13 07:13:25 PDT 2015
On Saturday, 13 June 2015 at 13:32:19 UTC, kerdemdemir wrote:
> One more question I am asking those kind of questions to
> understand and not ask same stuff over and over, :
>
> auto totalStr = chain(stringB.replicate(bCount),
> stringC.replicate(cCount));
> writeln(typeof(totalStr.array()).stringof);
> ---->dchar[]
>
> But
> auto totalStr = chain(stringB.repeat(bCount),
> stringC.repeat(cCount));
> writeln(typeof(totalStr.array()).stringof);
> ---->dchar[][]
>
> It seems to me a little inconsistent. range.repeat and
> array.replicate gives result in difference dimension.
>
> Is there any explanation or logic that I am missing which
> results this behaviour?
std.range.repeat is a lazy version unlike std.array.replicate:
5.repeat(3).writeln; // a lazy version // [5, 5, 5]
[5].replicate(3).writeln; // [5, 5, 5]
// but
[5].repeat(3).writeln; // a lazy version // [[5], [5], [5]]
More information about the Digitalmars-d-learn
mailing list