digitalmars.D - Associative arrays initialisation
- Stephan Wienczny (3/3) May 27 2004 Hallo,
- Stewart Gordon (9/12) May 28 2004 By waiting for
- Stephan Wienczny (3/18) May 28 2004 There is no language support for this?
- EricAnderton at yahoo dot com (15/17) May 28 2004 Yes, use "static this(){}" to insert init code in your module.
Hallo, how can I initialize constant associative arrays? Stephan
May 27 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"]); }
May 28 2004