Update rfcs/generalized-iteration.md

Co-authored-by: dcope-rbx <91100513+dcope-rbx@users.noreply.github.com>
This commit is contained in:
Arseny Kapoulkine 2022-02-02 10:05:01 -08:00 committed by GitHub
parent 36802f0c75
commit b5df447e5d
Signed by: DevComp
GPG key ID: 4AEE18F83AFDEB23

View file

@ -22,7 +22,7 @@ This proposal solves all of these by providing a way to implement uniform iterat
In Lua, `for vars in iter do` has the following semantics (otherwise known as the iteration protocol): `iter` is expanded into three variables, `gen`, `state` and `index` (using `nil` if `iter` evaluates to fewer than 3 results); after this the loop is converted to the following pseudocode: In Lua, `for vars in iter do` has the following semantics (otherwise known as the iteration protocol): `iter` is expanded into three variables, `gen`, `state` and `index` (using `nil` if `iter` evaluates to fewer than 3 results); after this the loop is converted to the following pseudocode:
``` ```lua
while true do while true do
vars... = gen(state, index) vars... = gen(state, index)
index = vars... -- copy the first variable into the index index = vars... -- copy the first variable into the index