Skip to content

Commit 5903b22

Browse files
BenjaminVanRyseghemmbeaudru
authored andcommitted
Fix generator example (mbeaudru#92)
The `downToOne` example returned the list in a reversed order
1 parent 01353e1 commit 5903b22

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1616,7 +1616,7 @@ function * downToOne(n) {
16161616
}
16171617
}
16181618

1619-
[...downToOne(5)] //[ 1, 2, 3, 4, 5 ]
1619+
[...downToOne(5)] //[ 5, 4, 3, 2, 1 ]
16201620
```
16211621

16221622
Generators return an iterable object. When the iterator's `next()` function is called, it is executed until the first `yield` expression, which specifies the value to be returned from the iterator or with `yield*`, which delegates to another generator function. When a `return` expression is called in the generator, it will mark the generator as done and pass back as the return value. Further calls to `next()` will not return any new values.

0 commit comments

Comments
 (0)