[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: [Q] newbie questions about timestamp, character code, ..
- From: "Jerome Vuarand" <jerome.vuarand@...>
- Date: Thu, 8 Feb 2007 17:13:42 -0500
Makoto Kuwata wrote:
> * How to check whether table has key or not?
if table[key]==nil then
print "Your table has no entry with that key"
end
You can't put nils in a table, neither as key or as values:
- table[key]=nil removes an entry from the table.
- table[nil]=value throws an error
Gergo Szakal wrote:
> if table[key] then ... end
>
> means that if the given key in the table is non-nil, then...
Note that false is a valid table value, and in that case the test above
will fail. To be sure a key is not used check explicitly against nil.