Match Expressions
match is Cangjie's pattern matching expression that selects which branch to execute based on a value. Each case branch contains a pattern and the code to execute, separated by =>.
Unlike switch in C or Java, Cangjie's match has no fallthrough behavior—only the matching branch executes, and no break is needed. Once a match succeeds and that branch executes, the entire match expression ends.
match expressions can return values. The value of the last line of code after => in each branch is the return value for that branch. The code below assigns the match result to the variable name.
Run the code and observe the output. Then try changing day on line 2 to 6 and see which branch matches.