From 7d05900c4bbe9630cc1bb93f88ea57bf7ddedde2 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Sat, 20 Jun 2009 22:47:12 +0100 Subject: util.array: Add support for + operator to create a new array from two arrays joined --- util/array.lua | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'util') diff --git a/util/array.lua b/util/array.lua index 8b9102bf..05e035df 100644 --- a/util/array.lua +++ b/util/array.lua @@ -5,6 +5,11 @@ local function new_array(_, t) return setmetatable(t or {}, array_mt); end +function array_mt.__add(a1, a2) + local res = new_array(); + return res:append(a1):append(a2); +end + setmetatable(array, { __call = new_array }); function array:map(func, t2) -- cgit v1.2.3