lua-users home
lua-l archive

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


> 1) Does lua_next() have to be always kick started by using lua_pushnil() or
> is it acceptable to push any key and the traversal will commence from that
> key?

The reference manual, which is the authority on all language matters,
says nothing about this. It only says that pushing nil will signal the
start of a full traversal.

In the current implementation, the traversal will commence from that key.
But that may change in the future, so don't count on it if the manual doesn't
say so.
 
> 2) If the answer to the above is true (pushing a key other than nil is
> acceptable), will lua_next() work if the key is not present in the table
> being traversed?

No, Lua will complain if the key is not present.

--lhf