OxL Reference

kw match

Reserved keyword

The list of words: §1.4

Syntax

ebnf
Match       = "match" Expr "{" { Pattern [ "if" Expr ] "=>" Expr ( "," | NL ) } "}" ;

Grammar: App. A

Defined in

Examples

oxl
match result {
  Receipt r if r.amount > LIMIT => review(r)
  Receipt r                     => ok(r)
  Declined(reason)              => warn(reason)
  Timeout | Unavailable         => retryLater()
  _                             => fail Unknown
}

— 5.5 Pattern matching

Related diagnostics

non-exhaustive, pattern-bindings, unreachable-arm, type-mismatch, not-assignable, fail-type, question-context, unhandled-error

See also