cangjie-pattern-match

Explain Cangjie pattern matching features including match expressions and pattern types.

2|Updated Mar 10, 2026
One-click install
npx skills add https://github.com/zhenzhizhi12/NexusAgent --skill cangjie-pattern-match-zhenzhizhi12
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cangjie-pattern-match
Source: https://github.com/zhenzhizhi12/NexusAgent/tree/main/.opencode/skills/common-skill-l1/pattern_match
Command: npx skills add https://github.com/zhenzhizhi12/NexusAgent --skill cangjie-pattern-match-zhenzhizhi12

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill clarifies the intricacies of Cangjie's pattern matching capabilities, enabling developers to write more robust and expressive code by understanding how to match various data structures and control program flow.

Core Features & Use Cases

  • match Expressions: Learn to use match for conditional logic based on data patterns, including exhaustive matching and default cases.
  • Pattern Types: Understand and utilize constant, wildcard, binding, tuple, type, and enum patterns.
  • Advanced Constructs: Explore pattern guards (where), if-let, while-let, and pattern usage in variable definitions and loops.
  • Use Case: When dealing with complex data structures like enums or tuples, use pattern matching to elegantly destructure and handle different cases, ensuring all possibilities are covered.

Quick Start

Use the cangjie-pattern-match skill to understand how to use a match expression with enum patterns.

Frequently Asked Questions about cangjie-pattern-match

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use pattern matching with enums in Cangjie?

Pattern matching with enums in Cangjie uses match expressions to destructure data and handle specific enum cases exhaustively. You define constant, wildcard, or binding patterns to execute conditional logic based on the matched enum variant.

What is the difference between if-let and while-let in Cangjie?

if-let and while-let in Cangjie provide conditional matching for single patterns. if-let executes a block once if a pattern matches, whereas while-let continuously loops and destructures as long as the pattern condition remains satisfied.

How do pattern guards work in Cangjie match expressions?

Pattern guards in Cangjie use the where clause to add boolean conditions to match arms. They refine pattern matching by evaluating additional expressions, ensuring the arm executes only if both the data pattern and the guard condition evaluate to true.

When should I use tuple patterns in Cangjie?

Tuple patterns in Cangjie should be used to destructure multiple values simultaneously within a match expression. They allow you to match and bind specific elements of a tuple data structure directly, simplifying conditional logic for grouped variables.

Does Cangjie require match expressions to be exhaustive?

Yes, Cangjie match expressions must be exhaustive, meaning every possible value must be handled. You achieve pattern exhaustiveness by covering all enum variants or including a wildcard pattern to catch any remaining unmatched cases.

Can I use pattern matching for variable definitions in Cangjie?

Yes, Cangjie allows pattern matching in variable definitions to destructure data directly during assignment. By using binding or tuple patterns, you can extract and bind internal components of complex data structures into distinct variables upon declaration.