[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Empty Table Manipulation
- From: Kristopher Lohmuller <tervalas@...>
- Date: Thu, 20 Apr 2006 15:08:53 -0500
I am a novice user of Lua so please excuse the lack of knowledge.
I'm trying to perform checks and other functions on an empty table, such
as table.getn(table). This was something I thought would give a result
of zero as per the first edition of Programming in Lua. However, I am in
actuality getting an error for trying to index a nil value. What is
upsetting more is that I've seen another script use this same call and
not generate an error.
To give more clarity on code:
disp = {};
if ((not disp) or (table.getn(disp)==0)) then
do stuff
end
Further on I try to use the same variable in a for statement:
for i,d in disp do
do things
end
This also is generating an error about trying to access a nil value.
Again, this is an exact copy of code that works, yet mine does not. Any
suggestions?