Are associative arrays stable in D?
Gary Willoughby
dev at nomad.so
Tue Jul 16 12:37:13 PDT 2013
Are associative arrays stable in D? I have to ask because i'm
having a great deal of problems with them for simple operations.
For example the following crashes.
import std.stdio;
void main(string[] args)
{
int[string] waiting;
waiting["gary"] = 1;
waiting["tess"] = 2;
foreach (string key; waiting.byKey())
{
writeln(key);
writeln(waiting[key]);
waiting.remove(key);
}
}
If however you remove the .byKey() call and use .keys instead, it
works!
Also if you remove the 'writeln(waiting[key]);' line from the
above code it prints about 40 blank lines.
More information about the Digitalmars-d-learn
mailing list