diff --git a/src/content/chapter0_basics/lesson04_type_checking/code.gleam b/src/content/chapter0_basics/lesson04_type_checking/code.gleam index e068f31..a724a6c 100644 --- a/src/content/chapter0_basics/lesson04_type_checking/code.gleam +++ b/src/content/chapter0_basics/lesson04_type_checking/code.gleam @@ -3,5 +3,8 @@ import gleam/io pub fn main() { io.println("My lucky number is:") // io.println(4) - // 👆️ Uncomment this line + // 👆️ Uncomment this line to see the error + + // echo 4 + // 👆️ You can use `echo` to debug print a value of any type! } diff --git a/src/content/chapter0_basics/lesson04_type_checking/en.html b/src/content/chapter0_basics/lesson04_type_checking/en.html index 0cffcbe..d23408f 100644 --- a/src/content/chapter0_basics/lesson04_type_checking/en.html +++ b/src/content/chapter0_basics/lesson04_type_checking/en.html @@ -15,11 +15,8 @@ function only works with strings, not ints.

- To fix the code change the code to call the - - io.debug - - function instead, as it will print a value of any type. + If you need to debug print something you can use the echo + keyword instead, as it will print a value of any type.

Gleam has no null, no implicit conversions, no exceptions, and diff --git a/src/content/chapter0_basics/lesson16_blocks/en.html b/src/content/chapter0_basics/lesson16_blocks/en.html index b19c586..1541bb2 100644 --- a/src/content/chapter0_basics/lesson16_blocks/en.html +++ b/src/content/chapter0_basics/lesson16_blocks/en.html @@ -7,11 +7,8 @@ Any variables assigned within the block can only be used within the block.

- Try uncommenting - - io.debug(degrees) - - to see the compile error from trying to use a variable that is not in scope. + Try uncommenting echo degrees to see the compile error from + trying to use a variable that is not in scope.

Blocks can also be used to change the order of evaluation of binary operators diff --git a/src/content/chapter1_functions/lesson07_pipelines/code.gleam b/src/content/chapter1_functions/lesson07_pipelines/code.gleam index 5156cb1..07ae4ef 100644 --- a/src/content/chapter1_functions/lesson07_pipelines/code.gleam +++ b/src/content/chapter1_functions/lesson07_pipelines/code.gleam @@ -8,12 +8,14 @@ pub fn main() { // With the pipe operator "Hello, Mike!" |> string.drop_right(1) + |> echo |> string.drop_left(7) |> io.println // Changing order with function capturing "1" |> string.append("2") + |> echo |> string.append("3", _) |> io.println } diff --git a/src/content/chapter1_functions/lesson07_pipelines/en.html b/src/content/chapter1_functions/lesson07_pipelines/en.html index 783ade9..927f9a8 100644 --- a/src/content/chapter1_functions/lesson07_pipelines/en.html +++ b/src/content/chapter1_functions/lesson07_pipelines/en.html @@ -23,3 +23,7 @@ position then a function capture can be used to insert the argument to the desired position.

+

+ If you need to debug print a value in the middle of a pipeline you can use + |> echo to do it. +

diff --git a/src/content/chapter3_data_types/lesson04_record_pattern_matching/code.gleam b/src/content/chapter3_data_types/lesson04_record_pattern_matching/code.gleam index 68bc7ef..1870d75 100644 --- a/src/content/chapter3_data_types/lesson04_record_pattern_matching/code.gleam +++ b/src/content/chapter3_data_types/lesson04_record_pattern_matching/code.gleam @@ -16,8 +16,8 @@ pub fn main() { fn handle_fish(fish: Fish) { case fish { - Starfish(_, favourite_color) -> io.debug(favourite_color) - Jellyfish(name, ..) -> io.debug(name) + Starfish(_, favourite_color) -> io.println(favourite_color) + Jellyfish(name, ..) -> io.println(name) } } @@ -25,5 +25,5 @@ fn handle_ice_cream(ice_cream: IceCream) { // if the custom type has a single variant you can // destructure it using `let` instead of a case expression! let IceCream(flavour) = ice_cream - echo flavour + io.println(flavour) } diff --git a/src/tour.gleam b/src/tour.gleam index 57461cf..bd5ff6c 100644 --- a/src/tour.gleam +++ b/src/tour.gleam @@ -60,11 +60,8 @@ const home_html = " io.println - or - - io.debug - - will be shown in the bottom section, along with any compile errors and warnings. + or echo will be shown in the bottom section, along with any compile + errors and warnings. To evaluate Gleam code the tour compiles Gleam to JavaScript and runs it, all entirely within your browser window.