From c2dcbe0f25a3e8bd60a4ccf377bbdd47f4794871 Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Tue, 26 Mar 2024 13:57:31 +0000 Subject: Document opaque types Closes https://github.com/gleam-lang/language-tour/issues/63 --- .../lesson04_let_assert/code.gleam | 16 ---------------- .../lesson04_let_assert/en.html | 15 --------------- 2 files changed, 31 deletions(-) delete mode 100644 src/content/chapter5_advanced_features/lesson04_let_assert/code.gleam delete mode 100644 src/content/chapter5_advanced_features/lesson04_let_assert/en.html (limited to 'src/content/chapter5_advanced_features/lesson04_let_assert') diff --git a/src/content/chapter5_advanced_features/lesson04_let_assert/code.gleam b/src/content/chapter5_advanced_features/lesson04_let_assert/code.gleam deleted file mode 100644 index 2ba907a..0000000 --- a/src/content/chapter5_advanced_features/lesson04_let_assert/code.gleam +++ /dev/null @@ -1,16 +0,0 @@ -import gleam/io - -pub fn main() { - let a = unsafely_get_first_element([123]) - io.debug(a) - - let b = unsafely_get_first_element([]) - io.debug(b) -} - -pub fn unsafely_get_first_element(items: List(a)) -> a { - // This will panic if the list is empty. - // A regular `let` would not permit this partial pattern - let assert [first, ..] = items - first -} diff --git a/src/content/chapter5_advanced_features/lesson04_let_assert/en.html b/src/content/chapter5_advanced_features/lesson04_let_assert/en.html deleted file mode 100644 index 29fd06c..0000000 --- a/src/content/chapter5_advanced_features/lesson04_let_assert/en.html +++ /dev/null @@ -1,15 +0,0 @@ -

- let assert is the final way to intentionally crash your Gleam - program. It is similar to the panic keyword in that it crashes - when the program has reached a point that should never be reached. -

-

- let assert is similar to let in that it is a way to - assign values to variables, but it is different in that the pattern can be - partial. The pattern does not need to match every possible value of the - type being assigned. -

-

- Like panic this feature should be used sparingly, and likely not - at all in libraries. -

-- cgit v1.2.3