Update for_iterators.md
This commit is contained in:
parent
728f51a2ee
commit
5adab192d0
1 changed files with 2 additions and 2 deletions
|
|
@ -22,7 +22,7 @@ iterator items(range: TRange): int =
|
||||||
inc i
|
inc i
|
||||||
|
|
||||||
iterator pairs(range: TRange): tuple[a: int, b: char] =
|
iterator pairs(range: TRange): tuple[a: int, b: char] =
|
||||||
for i in range:
|
for i in range: # uses Range.items
|
||||||
yield (i, char(i + ord('a')))
|
yield (i, char(i + ord('a')))
|
||||||
|
|
||||||
for i, c in TRange(low: 1, high: 3):
|
for i, c in TRange(low: 1, high: 3):
|
||||||
|
|
@ -112,6 +112,6 @@ echo output
|
||||||
```console
|
```console
|
||||||
$ nimrod c -r ./closure_iter.nim
|
$ nimrod c -r ./closure_iter.nim
|
||||||
0
|
0
|
||||||
12345678910111213141516171819200
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 0
|
||||||
0123456789
|
0123456789
|
||||||
```
|
```
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue