aboutsummaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-02-14 19:26:32 +0000
committerGinger Bill <bill@gingerbill.org>2017-02-14 19:26:32 +0000
commit71100ed427ee2eec8d8a9d4d9616102738097e80 (patch)
tree913d12b69a404635d0b2442262a300c7084b55bf /code
parent3ecf3505fd62c6aa10190a0be97e8572476e8c8b (diff)
Ternary expression (removed if and block expression)
Diffstat (limited to 'code')
-rw-r--r--code/demo.odin15
1 files changed, 6 insertions, 9 deletions
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);
}