Next pops a key from the stack and pushes a key-value pair from the table at index, while the table has next elements. If there are no more elements, nothing is pushed on the stack and Next returns false. A typical traversal looks like this: Table is on top of the stack (index -1). l.PushNil() //
(index int)
| 1189 | // |
| 1190 | // http://www.lua.org/manual/5.2/manual.html#lua_next |
| 1191 | func (l *State) Next(index int) bool { |
| 1192 | t := l.indexToValue(index).(*table) |
| 1193 | if l.next(t, l.top-1) { |
| 1194 | l.apiIncrementTop() |
| 1195 | return true |
| 1196 | } |
| 1197 | // no more elements |
| 1198 | l.top-- // remove key |
| 1199 | return false |
| 1200 | } |
| 1201 | |
| 1202 | // Concat concatenates the n values at the top of the stack, pops them, and |
| 1203 | // leaves the result at the top. If n is 1, the result is the single value |