Skip to content

Commit 6c4b74a

Browse files
authored
Replace it with elt / row / line etc (#1524)
* Replace `it` with `elt` / `row` / `line` etc. * `i18n.nu` * `make_docs.nu` * Replace `it` with `elt` / `row` / `line` etc in German translation * Replace `it` with `elt` / `row` / `line` etc in Portuguese translation * Replace `it` with `elt` / `row` / `line` etc in Mandarin translation * Replace `it` with `elt` / `row` / `line` etc in English docs * Replace `it` with `elt` / `row` / `line` etc in blog entries * Replace `it` with `elt` / `row` / `line` etc in misc scripts
1 parent 7b28d15 commit 6c4b74a

35 files changed

+149
-149
lines changed

blog/2022-03-22-nushell_0_60.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ In this release, we're also moving to keeping the current directory in the envir
272272
This allows you to more easily loop over subdirectories without having to do the bookkeeping of remembering to change back to the previous directory:
273273

274274
```
275-
> ls | where type == dir | each { |it| cd $it.name; ls | length }
275+
> ls | where type == dir | each { |row| cd $row.name; ls | length }
276276
```
277277

278278
That said, it takes a little getting used to. It does mean that changing a directory in a traditional custom command won't work, as the `PWD` environment variable will reset after the call completes. To help with this, we're also introducing `def-env`, a way to work inside the caller's environment and not lose any environment changes made by the custom command:
@@ -685,18 +685,18 @@ The new engine has a fun trick up it's sleeve: you can effortlessly convert your
685685
For example, if we had a script that opened files that fit a certain pattern and counted their number of lines:
686686

687687
```
688-
ls **/*.rs | each { |it|
689-
let num_lines = (open $it.name | lines | length)
690-
{name: $it.name, loc: $num_lines}
688+
ls **/*.rs | each { |row|
689+
let num_lines = (open $row.name | lines | length)
690+
{name: $row.name, loc: $num_lines}
691691
}
692692
```
693693

694694
We can turn this into a script that runs in parallel by changing the `each` to `par-each`:
695695

696696
```
697-
ls **/*.rs | par-each { |it|
698-
let num_lines = (open $it.name | lines | length)
699-
{name: $it.name, loc: $num_lines}
697+
ls **/*.rs | par-each { |row|
698+
let num_lines = (open $row.name | lines | length)
699+
{name: $row.name, loc: $num_lines}
700700
}
701701
```
702702

blog/2022-11-29-nushell-0.72.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ We have now split closures and blocks into two separate value types. A closure c
8282
An example closure:
8383

8484
```nu
85-
ls | each {|it| print $it.name }
85+
ls | each {|row| print $row.name }
8686
```
8787

8888
You can also think of creating a custom command like `def foo [] { ... }` as creating a closure.

blog/2024-01-09-nushell_0_89_0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ Setting the limits is done via flags available in `help ulimit`.
197197
let prs = list-merged-prs nushell/nushell $last_release_date
198198
| where author != "app/dependabot"
199199
| sort-by mergedAt
200-
| update url {|it| $"[#($it.number)]\(($it.url)\)" }
200+
| update url {|row| $"[#($row.number)]\(($row.url)\)" }
201201
| update author { $"[@($in)]\(https://github.com/($in)\)" }
202202
| select author title url
203203
| rename --column {url: pr}

blog/2024-02-06-nushell_0_90_0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ So if you have the following files: `aac.txt`, `abc.txt`, `a[ab]c.txt`, then:
113113
But if you save a file name in a variable, e.g: `let f = "a[ab]c.txt"`, then `ls $f` matches `aac.txt`, `abc.txt`.
114114
To escape the glob pattern to match a file named `a[bc]c.txt`, `str escape-glob` comes to play: `ls ($f | str escape-glob)`.
115115

116-
The new `str escape-glob` command ([#11663](https://github.com/nushell/nushell/pull/11664)) is useful when you want to prevent globs from expanding, for example when using a closure: `ls | str escape-glob name | each {|it| ls $it.name }`, so you won't get error occasionally.
116+
The new `str escape-glob` command ([#11663](https://github.com/nushell/nushell/pull/11664)) is useful when you want to prevent globs from expanding, for example when using a closure: `ls | str escape-glob name | each {|row| ls $row.name }`, so you won't get error occasionally.
117117

118118
## (Breaking Change!) For existing plugin
119119

blog/2024-05-15-top-nushell-hacks.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ git whatchanged -p --abbrev-commit --pretty=medium
7171
source: { |buffer, position|
7272
scope aliases
7373
| where name == $buffer
74-
| each { |it| {value: $it.expansion }}
74+
| each { |elt| {value: $elt.expansion }}
7575
}
7676
}
7777
```

book/cheat_sheet.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ iterate over a list; `it` is current list value:
180180

181181
```nu
182182
> let planets = [Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune]
183-
> $planets | each { |it| $"($it) is a planet of the solar system" }
183+
> $planets | each { |elt| $"($elt) is a planet of the solar system" }
184184
╭───┬─────────────────────────────────────────╮
185185
│ 0 │ Mercury is a planet of the solar system │
186186
│ 1 │ Venus is a planet of the solar system │
@@ -196,7 +196,7 @@ iterate over a list; `it` is current list value:
196196
iterate over a list with an index and value:
197197

198198
```nu
199-
> $planets | enumerate | each { |it| $"($it.index + 1) - ($it.item)" }
199+
> $planets | enumerate | each { |elt| $"($elt.index + 1) - ($elt.item)" }
200200
╭───┬─────────────╮
201201
│ 0 │ 1 - Mercury │
202202
│ 1 │ 2 - Venus │
@@ -213,15 +213,15 @@ reduce the list to a single value; `reduce` gives access to accumulator that is
213213

214214
```nu
215215
> let scores = [3 8 4]
216-
> $"total = ($scores | reduce { |it, acc| $acc + $it })"
216+
> $"total = ($scores | reduce { |elt, acc| $acc + $elt })"
217217
total = 15
218218
```
219219

220220
reduce with an initial value (`--fold`):
221221

222222
```nu
223223
> let scores = [3 8 4]
224-
> $"total = ($scores | reduce --fold 1 { |it, acc| $acc * $it })"
224+
> $"total = ($scores | reduce --fold 1 { |elt, acc| $acc * $elt })"
225225
total = 96
226226
```
227227

@@ -237,7 +237,7 @@ check if any string in the list starts with `E`:
237237

238238
```nu
239239
> let planets = [Mercury Venus Earth Mars Jupiter Saturn Uranus Neptune]
240-
> $planets | any {|it| $it | str starts-with "E" }
240+
> $planets | any {|elt| $elt | str starts-with "E" }
241241
true
242242
```
243243

book/control_flow.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ positive
351351
> positive-check (-3)
352352
non-positive
353353
354-
> let positive_check = {|it| if $it > 0 { return 'positive' }; 'non-positive' }
354+
> let positive_check = {|elt| if $elt > 0 { return 'positive' }; 'non-positive' }
355355
356356
> do $positive_check 3
357357
positive

book/custom_commands.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ Let's make our own command that doubles every value it receives as input:
467467

468468
```nu
469469
def double [] {
470-
each { |it| 2 * $it }
470+
each { |elt| 2 * $elt }
471471
}
472472
```
473473

book/line_editor.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ first clears the prompt, inserts a string and then enters that value
288288
event:[
289289
{ edit: Clear }
290290
{ edit: InsertString,
291-
value: "cd (ls | where type == dir | each { |it| $it.name} | str join (char nl) | fzf | decode utf-8 | str trim)"
291+
value: "cd (ls | where type == dir | each { |row| $row.name} | str join (char nl) | fzf | decode utf-8 | str trim)"
292292
293293
}
294294
{ send: Enter }
@@ -318,7 +318,7 @@ event to the engine
318318
mode: emacs
319319
event: {
320320
send: executehostcommand,
321-
cmd: "cd (ls | where type == dir | each { |it| $it.name} | str join (char nl) | fzf | decode utf-8 | str trim)"
321+
cmd: "cd (ls | where type == dir | each { |row| $row.name} | str join (char nl) | fzf | decode utf-8 | str trim)"
322322
}
323323
}
324324
]
@@ -763,7 +763,7 @@ With that in mind, the desired menu would look like this
763763
scope variables
764764
| where name =~ $buffer
765765
| sort-by name
766-
| each { |it| {value: $it.name description: $it.type} }
766+
| each { |row| {value: $row.name description: $row.type} }
767767
}
768768
}
769769
...

book/operators.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ operator can let you do it more easily.
148148
> [
149149
...$dogs
150150
Polly
151-
...($cats | each { |it| $"($it) \(cat\)" })
151+
...($cats | each { |elt| $"($elt) \(cat\)" })
152152
...[Porky Bessie]
153153
...Nemo
154154
]
@@ -169,7 +169,7 @@ The below code is an equivalent version using `append`:
169169
```nushell
170170
> $dogs |
171171
append Polly |
172-
append ($cats | each { |it| $"($it) \(cat\)" }) |
172+
append ($cats | each { |elt| $"($elt) \(cat\)" }) |
173173
append [Porky Bessie] |
174174
append ...Nemo
175175
```

0 commit comments

Comments
 (0)