lua-users home
lua-l archive

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


Alexander Gladysh wrote:
I've used 'false' in such cases, as table hole fillers.

Condition1 and C or D,
Condition2 and E or false,

Simple, but not perfect..


Thanks, but 1) this still require post-processing of the table and 2)
what if I'd want to create array of bools?

local nothing = {}

t = {
	(Condition1 and C) or (not Condition1 and D),
	(Condition2 and E) or (not Condition2 and nothing) ,
    }

...

local j = 1
for i = 1, table.maxn(t) do
   local v = t[i]
   if v == nil then break end
   if v ~= nothing then
      t[j], j = v, j+1
   end
end


Adrian