diff options
| author | gingerBill <bill@gingerbill.org> | 2019-12-22 12:03:48 +0000 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2019-12-22 12:03:48 +0000 |
| commit | d1c9fd4e012e16cee73e9ef0af716caf34430d81 (patch) | |
| tree | 048a9dd6ed2294d685761e31081620a924ee6ef9 /examples | |
| parent | 45937306321df28266c793b7225eb10ad3d741e2 (diff) | |
Implement `#complete switch` by default, replace with `#partial switch` #511
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/demo/demo.odin | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/examples/demo/demo.odin b/examples/demo/demo.odin index af9e606cb..062ea73b9 100644 --- a/examples/demo/demo.odin +++ b/examples/demo/demo.odin @@ -7,6 +7,7 @@ import "core:thread" import "core:reflect" import "intrinsics" + /* The Odin programming language is fast, concise, readable, pragmatic and open sourced. It is designed with the intent of replacing C with the following goals: @@ -1233,8 +1234,8 @@ implicit_selector_expression :: proc() { } -complete_switch :: proc() { - fmt.println("\n# complete_switch"); +partial_switch :: proc() { + fmt.println("\n# partial_switch"); { // enum Foo :: enum { A, @@ -1244,22 +1245,31 @@ complete_switch :: proc() { }; f := Foo.A; - #complete switch f { + switch f { case .A: fmt.println("A"); case .B: fmt.println("B"); case .C: fmt.println("C"); case .D: fmt.println("D"); case: fmt.println("?"); } + + #partial switch f { + case .A: fmt.println("A"); + case .D: fmt.println("D"); + } } { // union Foo :: union {int, bool}; f: Foo = 123; - #complete switch in f { + switch in f { case int: fmt.println("int"); case bool: fmt.println("bool"); case: } + + #partial switch in f { + case bool: fmt.println("bool"); + } } } @@ -1820,7 +1830,7 @@ main :: proc() { array_programming(); map_type(); implicit_selector_expression(); - complete_switch(); + partial_switch(); cstring_example(); bit_set_type(); deferred_procedure_associations(); |