fix table.insertkeyed

This commit is contained in:
Tom van Dijck 2017-11-30 10:01:07 -08:00
parent 5a0b07cd45
commit a37b9a291a

View File

@ -255,7 +255,7 @@
--
-- Inserts a value into a table as both a list item and a key-value pair.
-- Useful for set operations.
-- Useful for set operations. Returns false if the value already exists, true otherwise.
--
function table.insertkeyed(tbl, pos, value)
@ -263,8 +263,14 @@
value = pos
pos = #tbl + 1
end
if tbl[value] ~= nil then
return false
end
table.insert(tbl, pos, value)
tbl[value] = value
return true
end