Associative Array Non-null initialization
Kyle G.
kyle.james.gibson at gmail.com
Tue Oct 2 14:30:58 PDT 2007
Hi,
I want to declare an AA such that it's starting length is 0, yet, it is
not null.
For instance:
1 string[int] aa;
2 assert (aa.length == 0);
3 assert (aa is null);
4 aa[100] = "";
5 aa.remove(100);
6 assert (aa.length == 0);
7 assert (aa !is null);
The above runs without error, as it should. Notice that assertions 3 and
7 are opposite.
However, is there anything shorter/more efficient that I can do
(preferably on line 1) which would generate an AA which satisfies the
assertions 6 and 7?
This appears to function in the same way:
string[int] aa = [100:""];
aa.remove(100);
assert (aa.length == 0);
assert (aa !is null);
Thank you.
More information about the Digitalmars-d-learn
mailing list