Match a payload variant to use its fields.
if status is:
Ready => io.line("ready")
Failed(message) => io.line(message)
;
The capture name matches the field name.
Use as when the local name should be clearer:
Failed(message as error_text) => io.line(error_text)
Payload values are immutable. Pattern matching reads them without exposing direct field mutation.
Pattern matching inspects choice payloads.
if status is:
Ready => io.line("ready")
Waiting => io.line("waiting")
Failed(message) => io.line(message)
;
Capture contract
- A payload pattern must include every declared field.
- Captures stay in declaration order.
- Each source capture name must exactly match its declared field name.
as local_name renames only the arm-local binding.- Duplicate local binding names are invalid.
- Payload captures are immutable arm-local bindings.
- A valid payload arm covers the complete variant regardless of payload values.
Response ::
Pending |
retry_count Int,
message String,
|,
Complete,
;
if response is:
Pending(retry_count, message as pending_message) =>
io.line(pending_message)
Complete => io.line("done")
;
Deferred and rejected forms
Direct payload field access is deferred:
message = response.message
Payload field mutation is rejected.
Wildcard payload captures are not supported.
Named assignment is not match syntax:
Failed(message = text) => io.line(text)
Nested payload patterns and nested exhaustiveness are deferred.
See Patterns and exhaustiveness for match-level rules.