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

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue May 24 13:18:34 PDT 2016


On 5/24/16 4:03 PM, pineapple wrote:
> 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);

Slice assignment from range to array is not supported.

In your example, I'm curious why the efforts to specify the type? I 
think it would work with just saying auto itemstrings = ...

-Steve


More information about the Digitalmars-d-learn mailing list