From 2b7600b7451d1d3e74916fdd21a70fd10d1c56c0 Mon Sep 17 00:00:00 2001 From: Vanic Date: Sat, 9 May 2026 22:57:45 +0300 Subject: [PATCH] `Table`: add `table.remove_value` method --- mods/SYSTEM/Table/init.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mods/SYSTEM/Table/init.lua b/mods/SYSTEM/Table/init.lua index dd0292c..b5a5ad5 100644 --- a/mods/SYSTEM/Table/init.lua +++ b/mods/SYSTEM/Table/init.lua @@ -408,3 +408,17 @@ function table.key_value_list(t, separator) return result 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