From 3bfbe688f5a62e29835c7d3c4f282e7fff57949d Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Thu, 18 Jan 2024 17:47:12 +0000 Subject: Rename --- .../lesson00_use/text.html | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/content/chapter5_advanced_features/lesson00_use/text.html (limited to 'src/content/chapter5_advanced_features/lesson00_use/text.html') diff --git a/src/content/chapter5_advanced_features/lesson00_use/text.html b/src/content/chapter5_advanced_features/lesson00_use/text.html new file mode 100644 index 0000000..e295dda --- /dev/null +++ b/src/content/chapter5_advanced_features/lesson00_use/text.html @@ -0,0 +1,31 @@ +

+ Gleam lacks exceptions, macros, type classes, early returns, and a variety of + other features, instead going all-in with just first-class-functions and + pattern matching. This makes Gleam code easier to understand, but it can + sometimes result in excessive indentation. +

+

+ Gleam's use expression helps out here by enabling us to write code that uses + callbacks in an unindented style, as shown in the code window. +

+ +

+ The higher order function being called goes on the right hand side of the + <- operator. It must take a callback function as its final + argument. +

+

+ The argument names for the callback function go on the left hand side of the + <- operator. The function can take any number of arguments, + including zero. +

+

+ All the following code in the {} block becomes the + body of the callback function. +

+

+ This is a very capable and useful feature, but excessive application of + use may result in code that is unclear otherwise, especially to + beginners. Often using the regular function call syntax will result in more + approachable code! +

-- cgit v1.2.3