How to use an associative array with array values.

Adam D. Ruppe destructionator at gmail.com
Wed Mar 21 15:58:00 UTC 2018


On Wednesday, 21 March 2018 at 15:53:32 UTC, tipdbmp wrote:
> int[10][string] foo;

One option is to initialize like this

---
void main() {
    int[10][string] foo;

    if("a" !in foo)
	foo["a"] = [0,0,0,0,0,0,0,0,0,0]; // set all to zero to create 
the key

    foo["a"][4] = 4;  // now valid to set individual element
}
---


More information about the Digitalmars-d-learn mailing list