aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2019-03-06 20:06:37 +0000
committergingerBill <bill@gingerbill.org>2019-03-06 20:06:37 +0000
commit007a7989b83df0023ded1cd021ee55b341544840 (patch)
tree33d4884fcee9d5152ca1134fa72d4a099aa810ac
parent5c04800831d4b6b642d40e2866b88661cd8ac31e (diff)
Add implicit selector expression examples to demo.odin
-rw-r--r--examples/demo/demo.odin29
1 files changed, 29 insertions, 0 deletions
diff --git a/examples/demo/demo.odin b/examples/demo/demo.odin
index fd15b2a97..d65c83059 100644
--- a/examples/demo/demo.odin
+++ b/examples/demo/demo.odin
@@ -746,6 +746,34 @@ map_type :: proc() {
}
+implicit_selector_expression :: proc() {
+ fmt.println("# implicit selector expression");
+
+ Foo :: enum {A, B, C};
+
+ f: Foo;
+ f = .A;
+
+ BAR :: bit_set[Foo]{.B, .C};
+
+ switch f {
+ case .A:
+ fmt.println("HERE");
+ case .B:
+ fmt.println("NEVER");
+ case .C:
+ fmt.println("FOREVER");
+ }
+
+ my_map := make(map[Foo]int);
+ defer delete(my_map);
+
+ my_map[.A] = 123;
+ my_map[Foo.B] = 345;
+
+ fmt.println(my_map[.A] + my_map[Foo.B] + my_map[.C]);
+}
+
explicit_procedure_overloading :: proc() {
fmt.println("# explicit procedure overloading");
@@ -940,6 +968,7 @@ main :: proc() {
named_proc_return_parameters();
using_enum();
map_type();
+ implicit_selector_expression();
explicit_procedure_overloading();
complete_switch();
cstring_example();