aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2018-02-17 11:54:08 +0000
committergingerBill <bill@gingerbill.org>2018-02-17 11:54:08 +0000
commitc4d2d287fc0eac7348951ce275a1f3d80f25ef3d (patch)
treee082b0f1d744689ced0cdab73dd405981cacbf3a /examples
parent6a85546b761b67fa012a2cd49e32b2211bf02971 (diff)
#complete switch; Removal of dyncall
Diffstat (limited to 'examples')
-rw-r--r--examples/demo.odin52
1 files changed, 42 insertions, 10 deletions
diff --git a/examples/demo.odin b/examples/demo.odin
index 3ff904d88..85868e35b 100644
--- a/examples/demo.odin
+++ b/examples/demo.odin
@@ -729,17 +729,49 @@ explicit_procedure_overloading :: proc() {
// add(1, 2.0);
}
+complete_switch :: proc() {
+ { // enum
+ Foo :: enum #export {
+ A,
+ B,
+ C,
+ D,
+ }
+
+ b := Foo.B;
+ f := Foo.A;
+ #complete switch f {
+ case A...C: fmt.println("A...C");
+ // case A: fmt.println("A");
+ // case B: fmt.println("B");
+ // case C: fmt.println("C");
+ case D: fmt.println("D");
+ case: fmt.println("?");
+ }
+ }
+ { // union
+ Foo :: union {int, bool};
+ f: Foo = 123;
+ #complete switch _ in f {
+ case int: fmt.println("int");
+ case bool: fmt.println("bool");
+ case:
+ }
+ }
+}
+
main :: proc() {
when true {
- // general_stuff();
- // default_struct_values();
- // union_type();
- // parametric_polymorphism();
- // threading_example();
- // array_programming();
- // using_in();
- // named_proc_return_parameters();
- // enum_export();
- // explicit_procedure_overloading();
+ general_stuff();
+ default_struct_values();
+ union_type();
+ parametric_polymorphism();
+ threading_example();
+ array_programming();
+ using_in();
+ named_proc_return_parameters();
+ enum_export();
+ explicit_procedure_overloading();
+ complete_switch();
}
}