From ac1566762bdfea1e9cf27dfdad393352398bbab0 Mon Sep 17 00:00:00 2001 From: Ginger Bill Date: Mon, 19 Dec 2016 13:18:20 +0000 Subject: Golang style enumerations with `iota` --- code/demo.odin | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'code') 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); } -- cgit v1.2.3