You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: lang-guide/chapters/types/basic_types/closure.md
+15-15Lines changed: 15 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -15,8 +15,8 @@ Closures are used in Nu extensively as parameters to iteration style commands li
15
15
1. A closure can be directly invoked using the [`do`](/commands/docs/do.md) command.
16
16
17
17
```nu
18
-
> do {|a,b| $a + $b } 34 8
19
-
42
18
+
do {|a,b| $a + $b } 34 8
19
+
# => 42
20
20
```
21
21
22
22
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
35
35
- 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.
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
91
91
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:
92
92
93
93
```nu
94
-
> {|a,b| $a + $b} | do $in 34 8
95
-
43
94
+
{|a,b| $a + $b} | do $in 34 8
95
+
# => 43
96
96
```
97
97
98
98
1. As seen above, closures can be returned from a custom command. They can also be returned from another closure.
0 commit comments