How to make a static immutable associative array using assocArray in CT?

realhet real_het at hotmail.com
Tue Feb 10 21:52:52 UTC 2026


On Tuesday, 10 February 2026 at 21:14:29 UTC, monkyyy wrote:
> On Tuesday, 10 February 2026 at 20:46:11 UTC, realhet wrote:
>> Hi,
>
>
> ```d
> enum int[string] foo=(){
> 	int[string] o;
> 	o["hi"]=2;
> 	o["bye"]=3;
> 	o["hi"]=4;
> 	return o;
> }();
> ```

```d
static immutable foo = ["this":2, "works":3, "fine":4];
```

The problem occurs when I do it with assocArray() function and 
giving it the key and value ranges from an enum.

I want to automatize this dictionary because the contents of that 
enum will be changed/maintained later.





More information about the Digitalmars-d-learn mailing list