lua-users home
lua-l archive

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


> One more way with lua_isnil.
> 
> lua_pushstring(L, "key");
> lua_rawget(L, 1); // Assuming table is at index 1
> if (lua_isnil(L, -1)) {
>     // It's nil
> } else {
>     // It's something else
> }

Or else:

  lua_pushstring(L, "key");
  if (lua_rawget(L, 1) == LUA_TNIL) {  // Assuming table is at index 1
      // It's nil
  } else {
      // It's something else
  }

-- Roberto