From 835eb7e89627eea923bfd57bdacba7065c6b1d4c Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 15 Sep 2024 16:42:42 -0400 Subject: Add optional:or_exit(...) --- docs/optionals.md | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'docs/optionals.md') 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! ``` -- cgit v1.2.3