Skip to content
State: Approved

ADR#1475937194

pattern-matching

Pattern matching in function heads and control-flow

Context

Pattern matching in function heads should be used exclusively for control flow and not as a convenient way to extract values out of maps or structs.

This helps indicate to the reader of the code that the pattern matching influences the control-flow of the code and as-such runtime behaviour.

This is also outlined in the official docs as an anti-pattern

Resolution

  • You MUST pattern matching in function heads for control-flow purposes.
  • You MUST NOT use pattern matching in function heads as a convenience for destructuring variables out into the function body.

Except as otherwise noted, the content of this repository is licensed under the Creative Commons Attribution 4.0 License and code samples are licensed under the MIT