Table: add table.remove_value method
This commit is contained in:
@@ -408,3 +408,17 @@ function table.key_value_list(t, separator)
|
|||||||
|
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Finds and removes from the list all elements matching the value.
|
||||||
|
---@generic value any
|
||||||
|
---@param list value[]
|
||||||
|
---@param value value
|
||||||
|
---@param value[]
|
||||||
|
function table.remove_value(list, value)
|
||||||
|
local index = table.indexof(list, value)
|
||||||
|
while index ~= -1 do
|
||||||
|
list = table.remove(list, index)
|
||||||
|
end
|
||||||
|
|
||||||
|
return list
|
||||||
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user