aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-10-26 14:29:04 +0100
committergingerBill <bill@gingerbill.org>2019-10-26 14:29:04 +0100
commitd808f9eccf961a63630d6751c7367d8dc375c4b9 (patch)
tree9431337527e3226eb58add1338ed6b01d637e55f /examples
parent1734eb949f5f58c61c541695386b58c06124f9e6 (diff)
Add range_cache.cpp
Diffstat (limited to 'examples')
-rw-r--r--examples/demo/demo.odin20
1 files changed, 18 insertions, 2 deletions
diff --git a/examples/demo/demo.odin b/examples/demo/demo.odin
index 5ee9ded84..cd6ac6bf5 100644
--- a/examples/demo/demo.odin
+++ b/examples/demo/demo.odin
@@ -50,9 +50,9 @@ extra_general_stuff :: proc() {
i := i32(137);
ptr := &i;
- _ = (^f32)(ptr);
+ _ = (^f32)(ptr); // Call-based syntax
// ^f32(ptr) == ^(f32(ptr))
- _ = cast(^f32)ptr;
+ _ = cast(^f32)ptr; // Operator-based syntax
_ = (^f32)(ptr)^;
_ = (cast(^f32)ptr)^;
@@ -1188,6 +1188,21 @@ where_clauses :: proc() {
}
}
+ranged_fields_for_array_compound_literals :: proc() {
+ fmt.println("\n#ranged fields for array compound literals");
+ { // Normal Array Literal
+ foo := [?]int{1, 4, 9, 16};
+ fmt.println(foo);
+ }
+ i := 2;
+ foo := [?]int {
+ 0 = 123,
+ 5..9 = 54,
+ 10..<16 = i*3 + (i-1)*2,
+ };
+ fmt.println(foo); // [123, 0, 0, 0, 0, 54, 54, 54, 54, 54, 8, 8, 8, 8, 8]
+}
+
main :: proc() {
when true {
extra_general_stuff();
@@ -1210,6 +1225,7 @@ main :: proc() {
quaternions();
inline_for_statement();
where_clauses();
+ ranged_fields_for_array_compound_literals();
}
}