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() // Add nil entry on stack (need 2 free slots).
for l.Next(-2) {
	key := lua.CheckString(l, -2)
	val := lua.CheckString(l, -1)
	l.Pop(1) // Remove val, but need key for the next iter.

Next is referenced in 3 repositories