local test = { 2, 3, 4, 8, 9, 100, 20, 13, 15, 7, 11}
for i, v in ipairs( test ) do
if v % 2 == 0 then
table.remove(test, i)
end
end
for i, v in ipairs( test ) do
print(i .. "====" .. v)
end
local test = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p' }
local remove = { a = true, b = true, c = true, e = true, f = true, p = true }
local function dump(table)
for k, v in pairs( table ) do
print(k)
print(v)
print("*********")
end
end
function table.removeItem(list, item, removeAll)
local rmCount = 0
for i = 1, #list do
if list[i - rmCount] == item then
table.remove(list, i - rmCount)
if removeAll then
rmCount = rmCount + 1
else
break
end
end
end
end
for k, v in pairs( remove ) do
table.removeItem(test, k)
end
dump(test)