Initialising global associative array

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 6 12:07:44 PDT 2015


On Saturday, June 06, 2015 18:18:07 Paul via Digitalmars-d-learn wrote:
> I need a globally accessible AA of type string[string] and find
> that it won't compile unless I use the static this(){} method as
> described in this thread:
>
> http://forum.dlang.org/thread/owhfdwrpfuiehzpiuqux@forum.dlang.org#post-mailman.1522.1346449072.31962.digitalmars-d-learn:40puremagic.com
>
> I understand the concept of this() insofar as returning a
> reference to an object but what is 'this' in the context referred
> to? A reference to the module??
>
> It doesn't seem very intuitive (to me at least!) especially given
> that strings are immutable anyway.

It's talking about static constructors, which are functions that run before
main rather than being constructors which are tied to specific objects. If
you search for "static constructor" on this page, you'll find some
documentation on them:

http://dlang.org/class.html

Another place to read up on them would be Ali's book:

http://ddili.org/ders/d.en/modules.html

- Jonathan M Davis



More information about the Digitalmars-d-learn mailing list