Diff

util/array.lua @ 1371:9e45bdf55353

util.array: Add array:append() method, to append a new array to an existing one
author Matthew Wild <mwild1@gmail.com>
date Sat, 20 Jun 2009 22:43:54 +0100
parent 1027:fe2e3d3dba6a
child 1372:3b13bb57002e
line wrap: on
line diff
--- a/util/array.lua	Sat Jun 20 18:18:38 2009 +0500
+++ b/util/array.lua	Sat Jun 20 22:43:54 2009 +0100
@@ -52,6 +52,14 @@
 	end
 end
 
+function array:append(array)
+	local len,len2  = #self, #array;
+	for i=1,len2 do
+		self[len+i] = array[i];
+	end
+	return self;
+end
+
 function array.collect(f, s, var)
 	local t, var = {};
 	while true do