Skip to content

Commit aa30934

Browse files
authored
Use preferred commented output format (#1983)
1 parent ba23bda commit aa30934

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

lang-guide/chapters/types/basic_types/closure.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Closures are used in Nu extensively as parameters to iteration style commands li
1515
1. A closure can be directly invoked using the [`do`](/commands/docs/do.md) command.
1616

1717
```nu
18-
> do {|a,b| $a + $b } 34 8
19-
42
18+
do {|a,b| $a + $b } 34 8
19+
# => 42
2020
```
2121

2222
1. The `|args|` list can also contain 0 arguments (`||`) or more than one argument `|arg1,arg2|`
@@ -35,21 +35,21 @@ Closures are used in Nu extensively as parameters to iteration style commands li
3535
- However, the closure that is returned has "captured" the value represented by `$greeting` and can still access it later when the closure itself is called.
3636

3737
```nu
38-
> def create_greeter [ greeting: string ]: nothing -> closure {
39-
{|name| $"($greeting), ($name)" }
40-
}
38+
def create_greeter [ greeting: string ]: nothing -> closure {
39+
{|name| $"($greeting), ($name)" }
40+
}
4141
42-
> let greet = create_greeter "Hello"
42+
let greet = create_greeter "Hello"
4343
# Invoke the closure with `do`
44-
> do $greet Dalija
45-
Hello, Dalija
46-
> do $greet Ryan
47-
Hello, Ryan
44+
do $greet Dalija
45+
# => Hello, Dalija
46+
do $greet Ryan
47+
# => Hello, Ryan
4848
4949
# Redefine greet with a new greeting
50-
> let greet = create_greeter "Aloha"
51-
> do $greet Kai
52-
Aloha, Kai
50+
let greet = create_greeter "Aloha"
51+
do $greet Kai
52+
# => Aloha, Kai
5353
```
5454

5555
Note that the `create_greeter` only needs to be defined once.
@@ -91,8 +91,8 @@ Closures are used in Nu extensively as parameters to iteration style commands li
9191
1. You can also pass closures themselves into a pipeline assuming the next command knows how to consume it. For example, the `do` example can be rewritten as:
9292

9393
```nu
94-
> {|a,b| $a + $b} | do $in 34 8
95-
43
94+
{|a,b| $a + $b} | do $in 34 8
95+
# => 43
9696
```
9797

9898
1. As seen above, closures can be returned from a custom command. They can also be returned from another closure.

0 commit comments

Comments
 (0)