added as keyword for case. close #29

This commit is contained in:
2021-07-22 18:20:28 -06:00
parent a15bfe7da3
commit 9dd3016091
3 changed files with 13 additions and 0 deletions

View File

@@ -360,6 +360,13 @@
(case (Some 5)
((Some (or 6 5 4))
(Assert.pass))
(otherwise (Assert.fail)))
// In Haxe, name = Pattern can be used in switch/case to match values: https://haxe.org/manual/lf-pattern-matching-variable-capture.html
// In Kiss, the syntax for this is (as name pattern)
(case (Some (Some 5))
((Some (as inner (Some v)))
(Assert.equals 5 v)
(Assert.isTrue (Type.enumEq (Some 5) inner)))
(otherwise (Assert.fail))))
(defun _testMaps []