609 B
609 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>
...
end match
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: (str: String) => Int32
match str
case "foo" => 1
case "bar" => 2
case _ => 3
end match
end fn