cangjie-pattern-match

Explain Cangjie pattern matching with match expressions and pattern guards.

1|Updated Mar 14, 2026
One-click install
npx skills add https://github.com/SunriseSummer/CangjieDocValidator --skill cangjie-pattern-match
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: cangjie-pattern-match
Source: https://github.com/SunriseSummer/CangjieDocValidator/tree/main/.github/skills/pattern_match
Command: npx skills add https://github.com/SunriseSummer/CangjieDocValidator --skill cangjie-pattern-match

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps developers understand and effectively utilize Cangjie's sophisticated pattern matching capabilities, reducing bugs and improving code clarity.

Core Features & Use Cases

  • Match Expressions: Learn how to use match for conditional logic with exhaustive checking.
  • Pattern Types: Explore various patterns including constants, wildcards, bindings, tuples, types, and enums.
  • Advanced Constructs: Understand pattern guards (where), if-let, and while-let for conditional matching and looping.
  • Use Case: Debugging complex conditional logic or implementing robust data parsing based on different data structures.

Quick Start

Use the cangjie-pattern-match skill to demonstrate a match expression with enum patterns and a pattern guard.

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 in Cangjie to destructure enums?

Cangjie pattern matching uses the match expression to destructure enums by comparing values against specific enum variants, ensuring exhaustive checking for robust conditional logic across all possible data states.

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

Cangjie's if-let construct handles single conditional binding cases, whereas match expressions enforce exhaustive pattern checking across multiple enum variants or tuple structures to guarantee all branches are addressed.

How do I add conditions to Cangjie match arms using pattern guards?

Cangjie pattern guards use the where clause to apply additional boolean conditions within match expressions, allowing you to filter matched values and execute arms only when specific criteria are met.

Can I use nested patterns for tuple destructuring in Cangjie?

Cangjie supports nested patterns for tuple destructuring, allowing you to extract multiple values simultaneously within a single match expression to parse complex data structures efficiently.

Why does my Cangjie match expression fail with a refutability error?

Cangjie match expressions require exhaustive matching and fail with refutability errors when your patterns do not cover all possible enum variants or data structures, requiring a wildcard or complete branch coverage.

When should I use while-let for looping in Cangjie?

Cangjie's while-let construct is used for conditional looping, repeatedly matching a pattern and executing its block until the pattern refutes the evaluated value, which is ideal for processing iterative data streams.