diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-07-18 14:56:07 +0100 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-07-18 14:56:07 +0100 |
| commit | 193c7c82c83022fa16dff6cc611d5673753ece8f (patch) | |
| tree | 4dc2df7b4802372c27edcef6bf05ca8afcf51aff /code | |
| parent | f7d8ba408cae67179b87e738eda2dbc3f08cd305 (diff) | |
Default struct field values
Diffstat (limited to 'code')
| -rw-r--r-- | code/demo.odin | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/code/demo.odin b/code/demo.odin index 8afbe88b8..0dc3448bf 100644 --- a/code/demo.odin +++ b/code/demo.odin @@ -110,7 +110,7 @@ get_hash :: proc(s: string) -> u32 { } - +/* Vector :: struct(N: int, T: type) { using _: raw_union { using e: [N]T; @@ -140,11 +140,29 @@ foo1 :: proc(a: type/Vector) { fmt.println("foo1", a{}); } foo3 :: proc(a: type/Vector(3, $T)) {fmt.println("foo3", a{}); } // foo4 :: proc(a: type/Vector3) {} +*/ + +foo :: proc() -> (f32, f32) { + return 1, 2; +} main :: proc() { - foo1(Vector(3, f32)); + + Vector3 :: struct { + x: f32 = 1; + y: f32 = 4; + z: f32 = 9; + } + + v := make([dynamic]Vector3, 3); + + array: [100]Vector3; + v2 := array[50]; + fmt.println(v2); + +/* foo1(Vector(3, f32)); foo1(Vector3); foo3(Vector(3, f32)); foo3(Vector3); @@ -161,8 +179,9 @@ main :: proc() { v := add(a, b); fmt.println(v.v); +*/ - +/* table: Table(string, int); for i in 0..36 do put(&table, "Hellope", i); @@ -174,5 +193,5 @@ main :: proc() { found, _ = find(&table, "World!"); fmt.printf("found is %v\n", found); - +*/ } |