lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Dmitry Samersoff wrote:

Now it works.

No, your code is wrong. You messed up with the index to the copy of the key and value.


After lua_next() your stack looks:

 table key value *

The index of the key is -2, and the index of the value is -1.


After lua_pushvalue(L, -2) your stack looks:

  table key value copy_of_key *

You should work with the copy of the key. Its index is -1. Value's index is -2.


After lua_pop(L, 2) your stack looks:

  table key *


Got it?

Attachment: signature.asc
Description: OpenPGP digital signature