Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to declare and initialize an associative array with string as keys and arrays as value

Tags:

d

I am new to D. I am looking for the equivalent of this C++ declaration

typedef std::vector<std::string> the_value;
std::map<std::string,the_value> the_table;
like image 819
user841550 Avatar asked Sep 30 '22 15:09

user841550


1 Answers

You want something like this probably:

string[][string] the_table;

example:

import std.stdio;

void main(string[] args)
{
    string[][string] the_table = ["k1" : ["v1", "v2"], "k2" : ["v3", "v4"]];
    writeln(the_table);
}
like image 197
Kozzi11 Avatar answered Oct 12 '22 12:10

Kozzi11