Language Syntax
Pattern or — Python syntax
Try alternatives left to right and stop at the first successful pattern. Alternatives must bind the same set of names; only the final alternative may be irrefutable. This vertical bar is pattern syntax, not a bitwise expression.
Formal Syntax & Structure
python syntaxpython
case pattern1 | pattern2: suiteParameters & Attributes
| Name | Type | Description |
|---|---|---|
| pattern1 | pattern | First alternative. |
| pattern2 | pattern | Next alternative with identical binding set. |
Working Example
Example Snippetpython
match ('right',7): case ('left',n) | ('right',n): result=nprint(result)