Skip to content

Commit 5d9cf52

Browse files
committed
Use preferred commented output format
1 parent 6dbce64 commit 5d9cf52

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|`
@@ -34,21 +34,21 @@ Closures are used in Nu extensively as parameters to iteration style commands li
3434
- 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.
3535

3636
```nu
37-
> def create_greeter [ greeting: string ]: nothing -> closure {
38-
{|name| $"($greeting), ($name)" }
39-
}
37+
def create_greeter [ greeting: string ]: nothing -> closure {
38+
{|name| $"($greeting), ($name)" }
39+
}
4040
41-
> let greet = create_greeter "Hello"
41+
let greet = create_greeter "Hello"
4242
# Invoke the closure with `do`
43-
> do $greet Dalija
44-
Hello, Dalija
45-
> do $greet Ryan
46-
Hello, Ryan
43+
do $greet Dalija
44+
# => Hello, Dalija
45+
do $greet Ryan
46+
# => Hello, Ryan
4747
4848
# Redefine greet with a new greeting
49-
> let greet = create_greeter "Aloha"
50-
> do $greet Kai
51-
Aloha, Kai
49+
let greet = create_greeter "Aloha"
50+
do $greet Kai
51+
# => Aloha, Kai
5252
```
5353

5454
Note that the `create_greeter` only needs to be defined once.
@@ -77,8 +77,8 @@ Closures are used in Nu extensively as parameters to iteration style commands li
7777
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:
7878

7979
```nu
80-
> {|a,b| $a + $b} | do $in 34 8
81-
43
80+
{|a,b| $a + $b} | do $in 34 8
81+
# => 43
8282
```
8383

8484
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)