lua-l archive
[
Date Prev
][
Date Next
][
Thread Prev
][
Thread Next
] [
Date Index
] [
Thread Index
]
Subject
:
Checking if Table is Empty (C API)
From
: Marc Lepage <mlepage@
...
>
Date
: Tue, 19 Nov 2013 10:26:40 -0500
In Lua a good way to check if a table t is empty is to check if next(t) == nil.
What is the best way to check if a table is empty using the C API? Is it basically the same technique?
// table is on stack at index t
lua_pushnil(L); // nil key
if (lua_next(L, t))
{
// not empty
lua_pop(L, 2);
}
else
{
// empty
}
Or is there a better way?
Follow-Ups
:
Re: Checking if Table is Empty (C API)
,
Sir Pogsalot
Prev by Date:
Re: Lua Workshop 2013 unofficial pre-party
Next by Date:
Re: Lua Workshop 2013 unofficial pre-party
Previous by thread:
Re: Lua Workshop 2013 unofficial pre-party
Next by thread:
Re: Checking if Table is Empty (C API)
Index(es):
Date
Thread