aboutsummaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2016-12-19 13:18:20 +0000
committerGinger Bill <bill@gingerbill.org>2016-12-19 13:18:20 +0000
commitac1566762bdfea1e9cf27dfdad393352398bbab0 (patch)
tree9d1b7af076cae8d1323488069c32cb0fb6cf187b /code
parentf5eeecaca5842e4594ad2ed482c529a683bfb012 (diff)
Golang style enumerations with `iota`
Diffstat (limited to 'code')
-rw-r--r--code/demo.odin25
1 files changed, 24 insertions, 1 deletions
diff --git a/code/demo.odin b/code/demo.odin
index 759ed7951..61e1d5217 100644
--- a/code/demo.odin
+++ b/code/demo.odin
@@ -8,6 +8,29 @@
#import "sync.odin";
#import "utf8.odin";
+type float32 f32;
+const (
+ X = iota;
+ Y;
+ Z;
+ A = iota+1;
+ B;
+ C;
+);
+
+type Byte_Size f64;
+const (
+ _ = iota; // ignore first value by assigning to blank identifier
+ KB Byte_Size = 1 << (10 * iota);
+ MB;
+ GB;
+ TB;
+ PB;
+ EB;
+);
+
proc main() {
- fmt.println("Here");
+ fmt.println(X, Y, Z);
+ fmt.println(A, B, C);
+ fmt.println(KB, MB, GB, TB, PB, EB);
}