1
0
mirror of https://github.com/ruanyf/es6tutorial.git synced 2025-05-24 10:22:23 +00:00

docs(iterator): fix return()

This commit is contained in:
ruanyf 2018-07-06 10:36:01 +08:00
parent d4c8df426a
commit a46664f54a

View File

@ -511,7 +511,7 @@ for (let line of readLinesSync(fileName)) {
}
```
上面代码中,情况一输出文件的第一行以后,就会执行`return`方法,关闭这个文件;情况二输出所有行以后,执行`return`方法,关闭该文件;情况三会在执行`return`方法关闭文件之后,再抛出错误。
上面代码中,情况一输出文件的第一行以后,就会执行`return`方法,关闭这个文件;情况二会在执行`return`方法关闭文件之后,再抛出错误。
注意,`return`方法必须返回一个对象,这是 Generator 规格决定的。