Re: Initializing an associative array into a variable when it is created

2023-07-15 Thread Danilo via Digitalmars-d-learn
On Saturday, 15 July 2023 at 23:24:27 UTC, Alexander Zhirov wrote: There are the same number of elements everywhere (in the internal array). Sorry, forgot that part. Just add the size of the internal array (2 in this case): ```d string[2][string] arr = [ "one": ["abc", "def"],

Re: Initializing an associative array into a variable when it is created

2023-07-15 Thread Danilo via Digitalmars-d-learn
Works fine, if you add a semicolon at the end. ```d import std.stdio; void main() { string[][string] arr = [ "one": ["abc", "def"], "two": ["ghi", "jkl"], "three": ["mno", "pqr"] ]; writeln(arr); writeln(arr["two"]); writeln(arr["two"][0]); } ```

Initializing an associative array into a variable when it is created

2023-07-15 Thread Alexander Zhirov via Digitalmars-d-learn
I still don't understand how to make this entry correct. I have a static array that I want to use exactly as an array (the structure doesn't quite fit): ```d string[][string] arr = [ "one": ["abc", "def"], "two": ["ghi", "jkl"], "three": ["mno", "pqr"] ] ``` There are the same