From 71100ed427ee2eec8d8a9d4d9616102738097e80 Mon Sep 17 00:00:00 2001 From: Ginger Bill Date: Tue, 14 Feb 2017 19:26:32 +0000 Subject: Ternary expression (removed if and block expression) --- code/demo.odin | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'code') diff --git a/code/demo.odin b/code/demo.odin index 438488045..a3fee1555 100644 --- a/code/demo.odin +++ b/code/demo.odin @@ -9,18 +9,14 @@ main :: proc() { - x := type_info(int); - t1, ok := union_cast(^Type_Info.Integer)x; - _, ok = union_cast(^Type_Info.Integer)x; - t2 := union_cast(^Type_Info.Integer)x; - - + x: f32 = false ? 123 : 55; + fmt.println("Ternary:", x); /* /* Version 0.1.1 Added: - * Dynamic Arrays `[...]Type` + * Dynamic Arrays [dynamic]Type` * Dynamic Maps `map[Key]Value` * Dynamic array and map literals * Custom struct alignemnt `struct #align 8 { bar: i8 }` @@ -32,6 +28,7 @@ main :: proc() { * enum types have an implict `names` field, a []string of all the names in that enum * immutable variables are "completely immutable" - rules need a full explanation * `slice_to_bytes` - convert any slice to a slice of bytes + * `union_cast` allows for optional ok check Removed: * Maybe/option types @@ -101,7 +98,7 @@ main :: proc() { } { - x: [...]f64; + x: [dynamic]f64; reserve(x, 16); defer free(x); append(x, 2_000_000.500_000, 3, 5, 7); @@ -114,7 +111,7 @@ main :: proc() { } { - x := [...]f64{2_000_000.500_000, 3, 5, 7}; + x := [dynamic]f64{2_000_000.500_000, 3, 5, 7}; defer free(x); fmt.println(x); } -- cgit v1.2.3