Changeset

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
parents 1372:3b13bb57002e
children 1377:ae88b9dc7890
files util/array.lua
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
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)