What's wrong with my usage of std.algorithm.map in this code example?

pineapple via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue May 24 13:03:14 PDT 2016


I would've expected this to work, but instead I get a compile 
error. Is my syntax wrong? Is this just not a case that map can 
handle, and I should be doing something else?

     import std.algorithm : map;
     import std.conv : to;
     import std.stdio : writeln;
     import std.string : join;

     string test(Args...)(in Args items){
         immutable string[items.length] itemstrings = 
map!(to!string)(items);
         return join(itemstrings, ", ");
     }

     unittest{
         writeln(test(1, 2, 3, 4));
     }



More information about the Digitalmars-d-learn mailing list