lua-users home
lua-l archive

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

On Apr 9, 2008, at 11:50 PM, Javier Guerra wrote:

On Wed, Apr 9, 2008 at 3:39 PM, Eugen-Andrei Gavriloaie
<> wrote:
3. We now try to add a new value using your method. Let this value be the string "this is a string". lua_objlen(L, -2) + 1 evaluates to 4 in this

lua_objlen(L, -2) is the same as #t, and it returns a number such that
t[n] is not nil and t[n+1] is nil.  in this case it could be 1 or 4,
so lua_objlen(L, -2) + 1 could be 2 or 5, both of wich are empty
Ahaaa!!! This is what I was missing! :)
Anyway, made a test app and I was preparing to ask why the # operator applied on a table with 3 elements reports 4. But this is the answer.

Thank you so much!