Assigning global and static associative arrays

Jonathan M Davis jmdavisProg at gmx.com
Fri Aug 31 12:56:59 PDT 2012


On Friday, August 31, 2012 20:24:27 Philippe Sigaud wrote:
> On Fri, Aug 31, 2012 at 7:04 PM, ixid <nuaccount at gmail.com> wrote:
> > Thank you, that certainly makes sense.
> 
> If you're certain you won't need to modify it, you can make it a
> compile-time constant:
> 
> enum int[string] dayNumbers =
> [ "Monday" : 0, "Tuesday" : 1, "Wednesday" : 2,
> "Thursday" : 3, "Friday" : 4, "Saturday" : 5,
> "Sunday" : 6 ];
> 
> void main() {
> //Stuff
> }

Except that that allocates a new AA every time that you use dayNumbers. So, 
that's probably a bad idea.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list