diff options
author | Matthew Wild <mwild1@gmail.com> | 2009-06-20 22:47:12 +0100 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2009-06-20 22:47:12 +0100 |
commit | 7d05900c4bbe9630cc1bb93f88ea57bf7ddedde2 (patch) | |
tree | ff2bb091ef651b9903d529d2c83f6e6e4497d59e /util | |
parent | 38f157315aabc79dcb79d2bd836448ed9256c961 (diff) | |
download | prosody-7d05900c4bbe9630cc1bb93f88ea57bf7ddedde2.tar.gz prosody-7d05900c4bbe9630cc1bb93f88ea57bf7ddedde2.zip |
util.array: Add support for + operator to create a new array from two arrays joined
Diffstat (limited to 'util')
-rw-r--r-- | util/array.lua | 5 |
1 files changed, 5 insertions, 0 deletions
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) |