// DOCS NAVIGATION
Padrões em match_
SOURCE: content/docs/reference/06-referencia-rapida.md — 06 Referência Rápida / 8. Padrões em match / Patterns in match
| Padrão | Sintaxe | Exemplo |
|---|---|---|
| Literal inteiro | 42 | when 42 then ... |
| Literal string | "hello" | when "ok" then ... |
| Literal bool | true / false | when true then ... |
| Wildcard | _ | otherwise ... |
| Binding | nome | when x then println(x) |
| Enum unit | Enum::Var | when Cor::Azul then ... |
| Enum tuple | Enum::Var(a, b) | when Ponto::Par(x, y) then ... |
| Enum struct | Enum::Var { campo } | when Forma::Rect { w, h } then ... |
| Multi-padrão | pat1 | pat2 | when 1 | 2 then ... |
| Guard | when pat if cond then ... | Não implementado ainda |
Regra de exhaustividade / Exhaustiveness rule:
Todo match deve cobrir todos os casos possíveis. Use _ como wildcard.