mirror of
https://github.com/odin-lang/Odin.git
synced 2026-06-05 02:04:06 +00:00
Golang style enumerations with iota
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user