{"id":"language--enums-match","name":"Enums, payloads, and match","owner":"yeho","package":"language","kind":"language","signature":"enum Name { Case, Payload(Type value) }\nmatch value { Case { ... } Payload with name { ... } else { ... } }","description":"enum names a closed set of cases. Payload cases can carry one typed value, and match selects a branch with an optional binding.","context":"Use an enum when the valid states are finite and you want the compiler and reader to see every named possibility.","parameters":[],"returns":"","members":[],"tags":["cpu","else","enum","language","logic","match","with","yeho"],"updated":"2026-09-09","source":{"repository":"yeho","path":"parser_declarations.cpp parseEnumDecl; parser_statements.cpp parseMatchStatement; conformance payload-enum-patterns"},"status":"experimental","notes":["Plain enums are stable enough for ordinary use; richer payload matching remains experimental across targets.","The removed choice spelling is not accepted. Use enum."],"examples":[{"id":"complete","title":"Complete program","description":"Bind the explanation carried by a failed result and display it.","code":"enum Result\n{\n    Ready,\n    Failed(text reason)\n}\nResult result = Result.Failed(\"The player name is missing\")\nmatch result\n{\n    Result.Ready { Console.Log(\"Ready\") }\n    Result.Failed with reason { Console.Log(reason) }\n    else { Console.Log(\"Unknown result\") }\n}\n","tags":["cpu","language"],"run":"cpu-oracle","expected":null,"verifyRun":false,"manifest":"manifestVersion = \"2\"\npackage = \"api.example.language__enums_match\"\nversion = \"0.1.0\"\nlanguageEdition = \"yeho-core-2026.1\"\n\n[app]\nkind = \"headless\"\n","verification":"type checked","sha256":"ecb631406c0b2b8655964cb259f6ebc871aab2004b11d704f23024f9acf28cfd","checked":"2026-09-09","diagnostic":"","observedOutput":null,"checkedBackend":null}],"searchTerms":[],"url":"https://demonhunterlabs.com/academy/api?item=language--enums-match","json":"https://demonhunterlabs.com/reference/items/language--enums-match.json","markdown":"https://demonhunterlabs.com/reference/text/language--enums-match.md"}
