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

WhatMeWorry kheaser at gmail.com
Tue Jan 9 23:05:21 UTC 2018


enum SoundType { MUSIC = 0, SOUND_EFFECT };

struct Sound
{
     string     file;
     SoundType  musicOrSfx;
     void*      ptr;   // Mix_Chunk* for sfx;  Mix_Music* for 
music;
}

immutable Sound[string] soundLibrary  =   // line 148
[
     "SCRATCH"          : { file : "scratch.wav", musicOrSfx : 
SOUND_EFFECT, ptr : null },
     "BACKGROUND_TRACK" : { file : "beat.wav",    musicOrSfx : 
MUSIC,        ptr : null },
     "HIGH"             : { file : "high.wav",    musicOrSfx : 
SOUND_EFFECT, ptr : null }	
];	


I keep getting a
source\app.d(148,1): Error: not an associative array initializer




More information about the Digitalmars-d-learn mailing list