aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-15 16:42:42 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-15 16:42:42 -0400
commit835eb7e89627eea923bfd57bdacba7065c6b1d4c (patch)
tree68fd9832252e728ccf0c7277a5a2f492e41c261c /docs
parentfb37b0ee4253651cab10b41cc2e1f536b17b26d4 (diff)
Add optional:or_exit(...)
Diffstat (limited to 'docs')
-rw-r--r--docs/README.md5
-rw-r--r--docs/optionals.md11
2 files changed, 12 insertions, 4 deletions
diff --git a/docs/README.md b/docs/README.md
index 642293ce..13401f32 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -76,14 +76,15 @@ Exits the program with a given status and optionally prints a message.
**Usage:**
```markdown
-ask(message:Text = "", status:Int32 = 0[32]) -> Void
+ask(message:Text? = !Text, status:Int32 = 1[32]) -> Void
```
**Parameters:**
- `message`: If nonempty, this message will be printed (with a newline) before
exiting.
-- `status`: The status code that the program with exit with.
+- `status`: The status code that the program with exit with (default: 1, which
+ is a failure status).
**Returns:**
This function never returns.
diff --git a/docs/optionals.md b/docs/optionals.md
index 1414ca6a..54fe5f5c 100644
--- a/docs/optionals.md
+++ b/docs/optionals.md
@@ -30,7 +30,7 @@ having to use a more generalized form of `enum` which may have different naming
conventions and which would generate a lot of unnecessary code.
In addition to using conditionals to check for null values, you can also use
-`:or_else(fallback)` or `:or_fail()`:
+`:or_else(fallback)` or `:or_fail()` or `:or_exit()`:
```tomo
maybe_x := 5?
@@ -42,6 +42,13 @@ maybe_x := 5?
maybe_x = !Int
>> maybe_x:or_else(-1)
= -1 : Int
->> maybe_x:or_fail()
+>> maybe_x:or_fail("No value!")
# Failure!
+
+
+maybe_x = !Int
+>> maybe_x:or_exit()
+= -1 : Int
+>> maybe_x:or_exit("No value!")
+# Exit!
```