synt.stmt.match_case
¤
MatchCase
¤
Bases: Statement
A case
statement.
References
Source code in synt/stmt/match_case.py
guard
instance-attribute
¤
|
Pattern guard.
__init__
¤
|
Initialize a case
statement.
DO NOT USE THIS IN YOUR CODE!
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pattern |
IntoExpression
|
Match pattern. |
required |
guard |
IntoExpression | None
|
Pattern guard. |
required |
body |
Block
|
Case body. |
required |
Source code in synt/stmt/match_case.py
indented
¤
Source code in synt/stmt/match_case.py
MatchCaseBuilder
¤
Builder for MatchCase
.
Source code in synt/stmt/match_case.py
__init__
¤
|
Initialize a new builder.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pattern |
IntoExpression
|
Match pattern. |
required |
if_
¤
|
Set the guard.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
guard |
IntoExpression
|
Pattern guard. |
required |
Match
¤
Bases: Statement
The match
statement.
Examples:
Notes
Python views [x]
, (x)
, etc, as different case
nodes,
but Synt views them as the same.
Synt accepts any form of expression as case patterns,
and you must check yourself.
References
Source code in synt/stmt/match_case.py
__init__
¤
|
Initialize a new match
statement.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
subject |
IntoExpression
|
Match subject. |
required |
case_
¤
|
Append a new case.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
pattern |
IntoExpression
|
Match pattern. |
required |