From 47c2eca7dceae9fb4e6f687f70273fb262fa07a2 Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Fri, 9 Dec 2022 15:53:16 +0200 Subject: Add try! builtin --- examples/try.milch | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 examples/try.milch (limited to 'examples/try.milch') diff --git a/examples/try.milch b/examples/try.milch new file mode 100644 index 0000000..68d6cc2 --- /dev/null +++ b/examples/try.milch @@ -0,0 +1,6 @@ +(import "core/common") +(import "core/result") + +; calls read-file! and wraps the result in a Result/ok on success +; in case of error, calls Result/ex on the error string +(try! Result/ex (. Result/ok read-file!) "does-not-exist.txt") -- cgit v1.3