ava/pattern-matching.md

29 lines
581 B
Markdown

# Pattern Matching
TODO: This needs just more description and examples and pressure testing.
Ava supports pattern matching and value destructuring.
## The Match Expression
```
match <expr>
case <pattern> => <expr>
case <pattern> => <expr>
...
```
## The Default Case
The _default case_, `_`, is used to catch all unmatched cases. This can be used
to only match a partial set of possible values:
TODO: WIP gotta figure out functions.
```
fn example: String => Int32 is
str => match str
case "foo" => 1
case "bar" => 2
case _ => 3
```