ava/pattern-matching.md

581 B

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