Answers for "lua table delete key"

Lua
6

how to delete a key in a table lua

local test = {"a", "b", "c"}

local function removeKey(tbl, key)
	for k,v in pairs(tbl) do
    	if (v == key) then
        	table.remove(tbl, key)
        end
    end
end

removeKey(test, "c")
Posted by: Guest on August-30-2021

Browse Popular Code Answers by Language