On Friday, 2 December 2022 at 18:26:36 UTC, Steven Schveighoffer wrote:
>This is not an associative array initializer:
['A' : ['B': 0]]
Yet, this is:
(['A' : ['B': 0]])
This looks like the nested objects I use in JSON and doesn't need parentheses because it's built with JSON. For example, without the parentheses, the first one will not compile, but will compile when the individual objects are created:
void main()
{
alias letter = int[char];/*
letter[string] letters = [
"Upper" : ['A': 65],
"Lower" : ['a': 97]
]; //* not compile */
letter[string] letters = ([
"Upper" : ['A': 65],
"Lower" : ['a': 97]
]); // okay
letter[] up = [['A': 65], ['B': 66], ['C': 67]];
letter[] low = [['a': 97], ['b': 98], ['c': 99]];
letter[string] lets = [
"Upper" : up[0],
"Lower" : low[0]
]; // okay
assert(lets == letters);
}
SDB@79