lua-users home
lua-l archive

Re: Empty Table Manipulation

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


Luis Carvalho wrote:
if ((not disp) or (table.getn(disp)==0)) then
 do stuff
end
in Lua 5.1 becomes
if not disp or not next(disp) then
 -- do stuff
end
and
for i,d in disp do
 do things
end
becomes
for i,d in pairs(disp) do
 -- do stuff
end
or
for i,d in next, disp do
 -- do stuff
end
Cheers,
luis.
Thanks. For some reason 5.0 accepts the (not disp and not next(disp)), but it still doesn't like the alternatives in the for statement. Recognizes that they are valid calls, but still says it is expecting a table value for disp but that disp is nil. Odd thing is that it gives this error even if the table has a value.

AltStyle によって変換されたページ (->オリジナル) /