On Tuesday, 24 December 2013 at 14:39:16 UTC, Timon Gehr wrote:
On 12/24/2013 12:36 PM, Dfr wrote:
Let's say i have array of kind:

auto a = [["1","0000FF"], ["2", "00FF00"], ...];

Is there simple way to turn it into associative array of kind:

string[string] b = ["1": "0000FF", "2": "00FF00", ...];



void main(){
    import std.array, std.algorithm, std.typecons;
    auto a = [["1","0000FF"], ["2", "00FF00"], /+...+/];
    auto aa = a.map!(x=>tuple(x[0],x[1])).assocArray;

    import std.stdio;
    writeln(aa);
}

This example looks cleanest, but not compile with error:

Error: no property 'assocArray' for type 'MapResult!(__lambda9, immutable(char[][])[])'

Reply via email to