www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Associative arrays initialisation

reply Stephan Wienczny <Stephan Wienczny.de> writes:
Hallo,

how can I initialize constant associative arrays?

Stephan
May 27 2004
parent reply Stewart Gordon <smjg_1998 yahoo.com> writes:
Stephan Wienczny wrote:

 Hallo,
 
 how can I initialize constant associative arrays?

By waiting for 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
parent reply Stephan Wienczny <wienczny web.de> writes:
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 D/26695 to be dealt with. Stewart.

May 28 2004
parent EricAnderton at yahoo dot com <EricAnderton_member pathlink.com> writes:
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"]); }
May 28 2004