mirror of
https://github.com/hi-language/hi-language.github.io.git
synced 2026-01-14 08:38:36 +00:00
docs: update index.html
This commit is contained in:
11
index.html
11
index.html
@@ -178,21 +178,21 @@ Hi dispenses with boolean keywords in favor of canonical numeric values for trut
|
||||
|
||||
## Conditional Expressions
|
||||
|
||||
All conditional logic is handled by a single ternary expression structure, which always returns a value. The pipe symbol \`|\` separates the "else" case.
|
||||
All conditional logic is handled by a single ternary expression structure, which always returns a value.
|
||||
|
||||
\`\`\`javascript
|
||||
// if
|
||||
(1 < 2) ? { _("True") }
|
||||
|
||||
// if / else
|
||||
result: (1 > 2) ? { "A" } | { "B" } // result is "B"
|
||||
result: (1 > 2) ? { "A" } : { "B" } // result is "B"
|
||||
|
||||
// if / else if / else
|
||||
score: 75
|
||||
grade: (score >= 90) ? { "A" }
|
||||
| (score >= 80) ? { "B" }
|
||||
| (score >= 70) ? { "C" }
|
||||
| { "D" } // The final else case
|
||||
: (score >= 80) ? { "B" }
|
||||
: (score >= 70) ? { "C" }
|
||||
: { "D" } // The final else case
|
||||
|
||||
_(grade) // Prints "C"
|
||||
\`\`\`
|
||||
@@ -406,3 +406,4 @@ To create the initial Hi-to-JS transpiler, the following primitives and built-in
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user