Is there a way to get this associative array initialization to work?

Steven Schveighoffer schveiguy at yahoo.com
Wed Jan 10 16:29:52 UTC 2018


On 1/10/18 10:11 AM, Jacob Carlborg wrote:
> On 2018-01-10 00:19, Steven Schveighoffer wrote:
> 
>> https://issues.dlang.org/buglist.cgi?list_id=218715&longdesc=not%20an%20associative%20array%20initializer&longdesc_type=allwordssubstr&query_format=advanced&resolution=--- 
>>
>>
>> Note, I think you need at least Sound.SOUND_EFFECT, etc.
>>
>> This bug looks particularly relevant: 
>> https://issues.dlang.org/show_bug.cgi?id=11221
>>
>> I think it should really work.
> 
> It's not just in associative arrays it doesn't work. It basically only 
> works in variables declarations:
> 
> https://issues.dlang.org/show_bug.cgi?id=15692
> 

Right, but it doesn't work in variable declarations if that variable is 
part of an associative array.

In other words:

struct S
{
    int x;
}

struct T
{
    S s;
}

T t = {s: {x: 1}}; // nesting works here
S[] arr = [{x: 1}, {x:2}]; // and here
S[string] aa = ["first": {x: 1}, "second": {x: 2}]; // but not here???

-Steve


More information about the Digitalmars-d-learn mailing list