aboutsummaryrefslogtreecommitdiff
path: root/code/demo.odin
blob: 3680c89578225a6aa5a2d441a9801a3921a6dcb2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#import "fmt.odin";



main :: proc() {
	{
		Byte_Size :: enum f64 {
			_, // Ignore first value
			KB = 1<<(10*iota),
			MB,
			GB,
			TB,
			PB,
		}

		using Byte_Size;
		fmt.println(KB, MB, GB, TB, PB);
	}
	{
		x := if 1 < 2 {
			y := 123;
			give y-2;
		} else {
			give 0;
		};

		x += {
			x := 2;
			give x;
		};

		fmt.println("x =", x);
	}
	{
		list := []int{1, 4, 7, 3, 7, 2, 1};
		for value : list {
			fmt.println(value);
		}
		for val, idx : 12 ..< 17 {
			fmt.println(val, idx);
		}
		msg := "Hellope";
		for value : msg {
			fmt.println(value);
		}
	}
	{
		i := 0;
		while i < 2 {
			i += 1;
		}

		// Idiom to emulate C-style for loops
		while x := 0; x < 2 {
			defer x += 1;
			// Body of code
			// ++ and -- have been removed
		}
	}
}