From f70130322cd306268c5da12c1517dc5725615ae8 Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Thu, 15 Feb 2024 12:18:17 +0000 Subject: text -> en --- .../lesson02_result_module/en.html | 40 ++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/content/chapter4_standard_library/lesson02_result_module/en.html (limited to 'src/content/chapter4_standard_library/lesson02_result_module/en.html') diff --git a/src/content/chapter4_standard_library/lesson02_result_module/en.html b/src/content/chapter4_standard_library/lesson02_result_module/en.html new file mode 100644 index 0000000..4901afd --- /dev/null +++ b/src/content/chapter4_standard_library/lesson02_result_module/en.html @@ -0,0 +1,40 @@ +

+ The + gleam/result + standard library module contains functions for working with results. Gleam + programs will make heavy use of this module to avoid excessive nested case + expressions when calling multiple functions that can fail. +

+ +

+ map + updates a value held within the Ok of a result by calling a given function on + it. If the result is an error then the function is not called. +

+ +

+ try + runs a result returning function on the value held within an Ok of a result. + If the result is an error then the function is not called. This is useful for + chaining together multiple function calls that can fail, one after the other, + stopping at the first error. +

+ +

+ unwrap + extracts the success value from a result, or returning a default value if the + result is an error. +

+ +

+ Result functions are often used with pipelines to chain together multiple + calls to result returning functions. +

-- cgit v1.2.3