From f839fa17948310d474762f70b5905be596b50a77 Mon Sep 17 00:00:00 2001 From: Newaser Date: Thu, 3 Jul 2025 05:45:13 +0000 Subject: [PATCH] =?UTF-8?q?update=20lua/core/util.lua.=20=E6=83=B3?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=B8=80=E4=B8=AAtable.some=EF=BC=8C?= =?UTF-8?q?=E4=B8=8D=E6=83=B3=E5=86=8D=E7=94=A8table.find=E4=BB=A3?= =?UTF-8?q?=E6=9B=BF=E4=BA=86=F0=9F=98=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Newaser --- lua/core/util.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lua/core/util.lua b/lua/core/util.lua index 06f687b..3c79afa 100644 --- a/lua/core/util.lua +++ b/lua/core/util.lua @@ -258,6 +258,17 @@ function table.forEach(self, func) end end +---@generic T +---@param self T[] +---@param func fun(element: T, index: integer, array: T[]): boolean? +---@return boolean +function table.some(self, func) + for i, v in ipairs(self) do + if func(v, i, self) then return true end + end + return false +end + ---@generic T ---@param self T[] ---@param func fun(element: T, index: integer, array: T[]): boolean? -- Gitee