diff options
Diffstat (limited to 'src/content/chapter5_advance_features/lesson01_use_sugar/code.gleam')
-rw-r--r-- | src/content/chapter5_advance_features/lesson01_use_sugar/code.gleam | 30 |
1 files changed, 0 insertions, 30 deletions
diff --git a/src/content/chapter5_advance_features/lesson01_use_sugar/code.gleam b/src/content/chapter5_advance_features/lesson01_use_sugar/code.gleam deleted file mode 100644 index ac61062..0000000 --- a/src/content/chapter5_advance_features/lesson01_use_sugar/code.gleam +++ /dev/null @@ -1,30 +0,0 @@ -import gleam/io -import gleam/result - -pub fn main() { - let x = { - use username <- result.try(get_usename()) - use password <- result.try(get_password()) - use greeting <- result.map(log_in(username, password)) - greeting <> ", " <> username - } - - case x { - Ok(greeting) -> io.println(greeting) - Error(error) -> io.println_error(error) - } -} - -// Here are some pretend functions for this example: - -fn get_usename() { - Ok("alice") -} - -fn get_password() { - Ok("hunter2") -} - -fn log_in(_username: String, _password: String) { - Ok("Welcome") -} |