Fix: Replace conditional else : with | to resolve ambiguity

This commit is contained in:
2025-09-15 19:55:00 -07:00
parent bad7d5d7e8
commit 647eea073a

View File

@@ -178,21 +178,21 @@ Hi dispenses with boolean keywords in favor of canonical numeric values for trut
## Conditional Expressions ## Conditional Expressions
All conditional logic is handled by a single ternary expression structure, which always returns a value. All conditional logic is handled by a single ternary expression structure, which always returns a value. The pipe symbol \`|\` separates the "else" case.
\`\`\`javascript \`\`\`javascript
// if // if
(1 < 2) ? { _("True") } (1 < 2) ? { _("True") }
// if / else // if / else
result: (1 > 2) ? { "A" } : { "B" } // result is "B" result: (1 > 2) ? { "A" } | { "B" } // result is "B"
// if / else if / else // if / else if / else
score: 75 score: 75
grade: (score >= 90) ? { "A" } grade: (score >= 90) ? { "A" }
: (score >= 80) ? { "B" } | (score >= 80) ? { "B" }
: (score >= 70) ? { "C" } | (score >= 70) ? { "C" }
: { "D" } // The final else case | { "D" } // The final else case
_(grade) // Prints "C" _(grade) // Prints "C"
\`\`\` \`\`\`