Initializing assoc array to non-null

Jonathan M Davis jmdavisProg at gmx.com
Sat Jun 1 09:04:36 PDT 2013


On Saturday, June 01, 2013 20:21:42 d coder wrote:
> Greetings
> 
> Is there a way to initialize an associative array to a non-null (but still
> empty) state? The only way I know is by adding an element and then removing
> it. Did I miss something obvious? Basically I want to write lines 7-8 in
> the following code in a cleaner fashion. Any ideas?

Unfortunately, at the moment, I believe that that's the best that you can do -  
though it's trivial enough to write a function that does that for you so that 
you can make it a one-liner:

auto aa = initAA!(string[int])();

or

initAA(aa);

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list