From: Steven Barth Date: Thu, 30 Oct 2008 19:13:06 +0000 (+0000) Subject: luci.util.combine now also accepts single objects X-Git-Tag: 0.8.2~60 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=462d4572d947eab433624ccde227b7edd15d6fb2;p=oweals%2Fluci.git luci.util.combine now also accepts single objects --- diff --git a/libs/core/luasrc/util.lua b/libs/core/luasrc/util.lua index 77c763d14..6498a4976 100644 --- a/libs/core/luasrc/util.lua +++ b/libs/core/luasrc/util.lua @@ -320,16 +320,20 @@ function parse_units(ustr) return val end ---- Combines two or more numerically indexed tables into one. +--- Combines two or more numerically indexed tables and single objects into one table. -- @param tbl1 Table value to combine -- @param tbl2 Table value to combine -- @param ... More tables to combine -- @return Table value containing all values of given tables function combine(...) local result = {} - for i, a in ipairs(arg) do - for j, v in ipairs(a) do - result[#result+1] = v + for i, a in ipairs({...}) do + if type(a) == "table" then + for j, v in ipairs(a) do + result[#result+1] = v + end + else + result[#result+1] = a end end return result