fork download
  1. import std.stdio;
  2.  
  3. void main() {
  4. string values[string];
  5. values["hello"] = "world";
  6.  
  7. writeln("Before clearing:");
  8. foreach (k,v; values) {
  9. writefln("[%s] = %s", k, v);
  10. }
  11.  
  12. foreach (k; values.keys) {
  13. values.remove(k);
  14. }
  15.  
  16. writeln("After clearing:");
  17. foreach (k,v; values) {
  18. writefln("[%s] = %s", k, v);
  19. }
  20. }
Success #stdin #stdout 0.01s 2076KB
stdin
Standard input is empty
stdout
Before clearing:
[hello] = world
After clearing: