Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,40 @@
|
|||
import std.stdio: writeln;
|
||||
|
||||
void main() {
|
||||
// the associative array
|
||||
auto aa = ["alice":2, "bob":97, "charlie":45];
|
||||
|
||||
// how to iterate key/value pairs:
|
||||
foreach (key, value; aa)
|
||||
writeln("1) Got key ", key, " with value ", value);
|
||||
writeln();
|
||||
|
||||
// how to iterate the keys:
|
||||
foreach (key, _; aa)
|
||||
writeln("2) Got key ", key);
|
||||
writeln();
|
||||
|
||||
// how to iterate the values:
|
||||
foreach (value; aa)
|
||||
writeln("3) Got value ", value);
|
||||
writeln();
|
||||
|
||||
// how to extract the values, lazy:
|
||||
foreach (value; aa.byValue())
|
||||
writeln("4) Got value ", value);
|
||||
writeln();
|
||||
|
||||
// how to extract the keys, lazy:
|
||||
foreach (key; aa.byKey())
|
||||
writeln("5) Got key ", key);
|
||||
writeln();
|
||||
|
||||
// how to extract all the keys:
|
||||
foreach (key; aa.keys)
|
||||
writeln("6) Got key ", key);
|
||||
writeln();
|
||||
|
||||
// how to extract all the values:
|
||||
foreach (value; aa.values)
|
||||
writeln("7) Got value ", value);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue