www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - appender!(string[]).put(string) doesn't work

reply David Held <dmd wyntrmute.com> writes:
    auto data = appender!(string[]);
    ...
    data.put(someString);

source\colony.d(360): Error: template 
std.array.Appender(string[]).Appender.put does not match any function 
template declaration. Candidates are:
D:\D\dmd2\windows\bin\..\..\src\phobos\std\array.d(2251): 
std.array.Appender!(string[]).Appender.put(U)(U item) if (canPutItem!U)
D:\D\dmd2\windows\bin\..\..\src\phobos\std\array.d(2279): 
std.array.Appender!(string[]).Appender.put(Range)(Range items) if 
(canPutConstRange!Range)
D:\D\dmd2\windows\bin\..\..\src\phobos\std\array.d(2288): 
std.array.Appender!(string[]).Appender.put(Range)(Range items) if 
(canPutRange!Range)
source\colony.d(360): Error: template 
std.array.Appender!(string[]).Appender.put(U)(U item) if (canPutItem!U) 
cannot deduce template function from argument types !()(char[])

The example in the documentation implies that this should work fine. 
What am I missing?

Dave
Feb 08 2015
parent David Held <dmd wyntrmute.com> writes:
On 2/8/2015 4:09 PM, David Held wrote:
     auto data = appender!(string[]);
     ...
     data.put(someString);
 [...]
Never mind. someString is actually the result of stdin.byLine(), which returns a char[], not a string. I didn't notice this until just now. .idup fixes this just fine (although, I suppose changing it to char[][] might be even better). Dave
Feb 08 2015