Thread overview
Associative arrays initialisation
May 28, 2004
Stephan Wienczny
May 28, 2004
Stewart Gordon
May 28, 2004
Stephan Wienczny
May 28, 2004
Hallo,

how can I initialize constant associative arrays?

Stephan
May 28, 2004
Stephan Wienczny wrote:

> Hallo,
> 
> how can I initialize constant associative arrays?

By waiting for

http://www.digitalmars.com/drn-bin/wwwnews?D/26695

to be dealt with.

Stewart.

-- 
My e-mail is valid but not my primary mailbox, aside from its being the unfortunate victim of intensive mail-bombing at the moment.  Please keep replies on the 'group where everyone may benefit.
May 28, 2004
There is no language support for this?
Do modules have automatic initializer functions I could use for that?

Stewart Gordon wrote:
> Stephan Wienczny wrote:
> 
>> Hallo,
>>
>> how can I initialize constant associative arrays?
> 
> 
> By waiting for
> 
> http://www.digitalmars.com/drn-bin/wwwnews?D/26695
> 
> to be dealt with.
> 
> Stewart.
> 
May 28, 2004
In article <c97bl2$18i5$1@digitaldaemon.com>, Stephan Wienczny says...
>
>There is no language support for this?
>Do modules have automatic initializer functions I could use for that?

Yes, use "static this(){}" to insert init code in your module.

alias char[] dstring;

// we really would like to use the following syntax, which isn't supported (yet) //dstring b[dstring] = ["one":"foo","two":"bar"];

// so do this instead:
dstring b[dstring];
static this(){
b["one"] = "foo";
b["two"] = "bar";
}

// prints out 'test: foobar' witout any trouble
void main(){
printf("test: %.*s%.*s\n",b["one"],b["two"]);
}