example.d 896 B

1234567891011121314151617181920212223242526272829303132333435
  1. module abc.
  2. def. gh;
  3. import std.stdio; // for writefln()
  4. import std . // system2;
  5. system ;
  6. //static import std.date, std.thread /+ /+ +/ , std.io +/ ;
  7. import testlib.code;
  8. int main(string[] args) // string is a type alias for const(char)[]
  9. {
  10. // Declare an associative array with string keys and
  11. // arrays of strings as data
  12. char[][] [char[]] container;
  13. int result = test_lib();
  14. // Add some people to the container and let them carry some items
  15. container["Anya"] ~= cast(char[]) "scarf";
  16. container["Dimitri"] ~= cast(char[]) "tickets";
  17. container["Anya"] ~= cast(char[]) "puppy";
  18. // Iterate over all the persons in the container
  19. foreach (const(char)[] person, char[][] items; container)
  20. display_item_count(cast(char[]) person, items);
  21. return 0;
  22. }
  23. void display_item_count(char[] person, char[][] items)
  24. {
  25. writefln(person, " is carrying ", items.length, " items");
  26. }