aboutsummaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-01-01 16:18:50 +0000
committerGinger Bill <bill@gingerbill.org>2017-01-01 16:18:50 +0000
commit6fef74317cdd0e403fb913ebe965dc08b3dfb22d (patch)
tree9f25deab9276dc60847c0548d1024cfdbc3679d4 /code
parent0c6775ca14ced37ac58a03ccad4028e225bda7d6 (diff)
Bring back `enum` but using iota
Diffstat (limited to 'code')
-rw-r--r--code/demo.odin28
1 files changed, 22 insertions, 6 deletions
diff --git a/code/demo.odin b/code/demo.odin
index 422b68c77..bd4ab5dcd 100644
--- a/code/demo.odin
+++ b/code/demo.odin
@@ -11,11 +11,27 @@ import {
win32 "sys/windows.odin";
}
+type Thing enum f64 {
+ _, // Ignore first value
+ A = 1<<(10*iota),
+ B,
+ C,
+ D,
+}
+
proc main() {
- var x = if false {
- give 123;
- } else {
- give 321;
- };
- fmt.println(x);
+ var ti = type_info(Thing);
+ match type info : type_info_base(ti) {
+ case Type_Info.Enum:
+ for var i = 0; i < info.names.count; i++ {
+ if i > 0 {
+ fmt.print(", ");
+ }
+ fmt.print(info.names[i]);
+ }
+ fmt.println();
+ }
+
+ fmt.println(Thing.A, Thing.B, Thing.C, Thing.D);
+
}