lua-users home
lua-l archive

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


On 09.01.2011 13:04, Alexander Gladysh wrote:

 And even with this strange scheme, where's the need to insert nil's?
 To clarify: I only see nil assignments when an element is taken out of the
 queue and no uses of table.insert(t, n, nil)
 It occurs if get_next_task() returns nil here:

 table.insert(t, #t, get_next_task())

Wouldn't it be even better if you write
local v = get_next_task()
if v ~= nil then
  table.insert(t, #t, v)
end

BTW, in 5.2 length operator can be overridden for tables, right? So,
inserting nil's should actually be completely normal for a vector with
fixed length.

--
Best regards,
Sergey Rozhenko                 mailto:sergroj@mail.ru