Software /
code /
prosody
Diff
util/array.lua @ 1373:120275376bbb
util.array: Add support for + operator to create a new array from two arrays joined
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sat, 20 Jun 2009 22:47:12 +0100 |
parent | 1372:3b13bb57002e |
child | 1522:569d58d21612 |
line wrap: on
line diff
--- a/util/array.lua Sat Jun 20 22:45:07 2009 +0100 +++ b/util/array.lua Sat Jun 20 22:47:12 2009 +0100 @@ -5,6 +5,11 @@ 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)