HaxeFoundation / HaxeFoundation/HaxeManual

Switch/case documentation gotcha

Open
#436 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Haxe
Stars
225
Forks
156
Avg merge
5h 16m
Merged PRs (30d)
1

Description

"Unintuitively", Haxe cases are absolutely strict, so this can bite:
```
switch (x) {
case 1:
case 2: trace('1 or 2'); // nope, never fall through
}
```
And the documentation doesn't explain how to declare a case matching several values - though it is explained deeper in the pattern matching documentation.

Still it's a bit confusing: is it `case 1, 2:` or `case 1 | 2:`?

It would be nice for beginners to add something.

Contributor guide

No contributing guide indexed for this repository

Research direction

Read the switch/case documentation alongside the pattern matching documentation referenced in the issue. Clarify that cases do not fall through and document the syntax for matching several values, with an example that beginners can verify against Haxe's existing behavior.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.