appender!(dchar[]) put fail

kerdemdemir via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 13 05:02:08 PDT 2015


> The problem is that your appender is a char appender, and you 
> try to put a dstring into it. Replace :
>
> charAppender.put(totalStr);
>
> by :
>
> foreach(elem; totalStr){
>    charAppender.put(elem);
> }
>
> elem will be a dchar, so it will work.


But I can see in the example of 
array.appander(http://dlang.org/phobos/std_array.html#appender)

int[] a = [ 1, 2 ];
auto app2 = appender(a);
app2.put(3);
app2.put([ 4, 5, 6 ]);  ---> appender accepts another array.

Why this is not same with dchar ?


More information about the Digitalmars-d-learn mailing list