[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to find out whether there is a specific key for a given Lua table besides traversing the whole table?
- From: 孙世龙 sunshilong <sunshilong369@...>
- Date: Thu, 14 Jan 2021 20:12:47 +0800
Spar > Use lua_getfield or lua_rawget with lua_type and LUA_TNIL
Could you please give me an example to achieve this goal by using
`lua_rawgetp`.
If the key exists, it must be a string whose name is known before.
On Thu, Jan 14, 2021 at 7:54 PM Spar <developspartv@gmail.com> wrote:
>
> Why didn't you specify that you need C API solution?
>
> Use lua_getfield or lua_rawget with lua_type and LUA_TNIL
> On 14 Jan 2021, 14:43 +0300, 孙世龙 sunshilong <sunshilong369@gmail.com>, wrote:
>
> Simply check if yourtable[yourkey] is nil
>
> This is a Lua script.
> How to achieve this goal(i.e the subject) by C api?
>
> On Thu, Jan 14, 2021 at 6:07 PM Luiz Henrique de Figueiredo
> <lhf@tecgraf.puc-rio.br> wrote:
>
>
> Cross-posted to
> https://stackoverflow.com/questions/65716853/how-to-find-out-whether-there-is-a-specific-key-for-a-given-lua-table-besides-tr