From 8b538587ad2f938138fe8d593b3bb6a36e9fbb38 Mon Sep 17 00:00:00 2001 From: Lars Mueller Date: Fri, 30 Sep 2022 15:31:11 +0200 Subject: [PATCH] Add table.clear --- table.lua | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/table.lua b/table.lua index e280346..3aea733 100644 --- a/table.lua +++ b/table.lua @@ -400,6 +400,12 @@ function is_empty(table) return next(table) == nil end +function clear(table) + for k in pairs(table) do + table[k] = nil + end +end + function foreach(table, func) for k, v in pairs(table) do func(k, v)