aboutsummaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-02-06 20:54:51 +0000
committerGinger Bill <bill@gingerbill.org>2017-02-06 20:54:51 +0000
commitf11d73ffaa5df21437714e73bb72352ed17d57a9 (patch)
treecd0886e33cd7bf02194619c47b44cc2c359f5865 /code
parentc126339090a57ab29a2c75d3ee79333cf3c88278 (diff)
`map` string keys and `for` iterator
Diffstat (limited to 'code')
-rw-r--r--code/demo.odin14
1 files changed, 9 insertions, 5 deletions
diff --git a/code/demo.odin b/code/demo.odin
index d44f7dca3..c4e44aebd 100644
--- a/code/demo.odin
+++ b/code/demo.odin
@@ -11,14 +11,18 @@
main :: proc() {
- m: map[int]u32;
+ m: map[string]u32;
reserve(^m, 16);
defer free(m);
- m[123] = 345;
- fmt.println(m[123]);
- if x, ok := m[123]; ok {
- fmt.println(x);
+ m["a"] = 56;
+ m["b"] = 13453;
+ m["c"] = 7654;
+ c, ok := m["c"];
+ assert(ok && c == 7654);
+
+ for val, key in m {
+ fmt.printf("m[\"%s\"] == %v\n", key, val);
}