match¶
Hook for match / case statements. Takes a dict where the keys are matched to a value. If the case value has an arrow in it (ie key->: ... ) the arrow is stripped away. All matched values are ran as hooks.
Inputs¶
Name | Type | Default | Required | Description |
---|---|---|---|---|
value | str | int | float | bool |
case | dict | True | A dictionary where the keys are cases to be matched. Runs hooks if present. |
Arguments¶
Position | Argument | Type |
---|---|---|
1 | value | str |
Returns¶
Union[list, dict, NoneType]
Examples¶
The match
hook mimics common match/case statements
# Stand in for some kind of thing to match against
selection:
->: select What to do?
choices: ['agree','disagree']
matcher:
->: match selection
case:
agree: Some value
disagree->: # Run some tackle context
...