Initializing an associative array into a variable when it is created
Alexander Zhirov
azhirov1991 at gmail.com
Sun Jul 16 12:06:07 UTC 2023
On Sunday, 16 July 2023 at 11:16:55 UTC, Danilo wrote:
> Would a static constructor be okay? This way the static data
> is not initialized at every `new` and object creation is faster.
Alternatively, i can think about your proposal. At the moment, I
have solved my problem using the following method:
```d
@property string[][string] arr() {
return [
"one": ["abc", "def"],
"two": ["ghi", "jkl"],
"three": ["mno", "pqr"]
];
}
```
I don't know how true it will be considered. After all, the
function creates an array every time it is called, which is not
correct.
More information about the Digitalmars-d-learn
mailing list