Software /
code /
prosody
Comparison
util/array.lua @ 7699:9c40d0be2295
util.array: Rename arguments to avoid name clash [luacheck]
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Tue, 18 Oct 2016 15:16:18 +0200 |
parent | 7020:6ab9c691c4c6 |
child | 7700:0d70410efdcf |
comparison
equal
deleted
inserted
replaced
7698:edacd0bef0e8 | 7699:9c40d0be2295 |
---|---|
17 local type = type; | 17 local type = type; |
18 | 18 |
19 local array = {}; | 19 local array = {}; |
20 local array_base = {}; | 20 local array_base = {}; |
21 local array_methods = {}; | 21 local array_methods = {}; |
22 local array_mt = { __index = array_methods, __tostring = function (array) return "{"..array:concat(", ").."}"; end }; | 22 local array_mt = { __index = array_methods, __tostring = function (self) return "{"..self:concat(", ").."}"; end }; |
23 | 23 |
24 local function new_array(self, t, _s, _var) | 24 local function new_array(self, t, _s, _var) |
25 if type(t) == "function" then -- Assume iterator | 25 if type(t) == "function" then -- Assume iterator |
26 t = self.collect(t, _s, _var); | 26 t = self.collect(t, _s, _var); |
27 end | 27 end |
113 self[i], self[r] = self[r], self[i]; | 113 self[i], self[r] = self[r], self[i]; |
114 end | 114 end |
115 return self; | 115 return self; |
116 end | 116 end |
117 | 117 |
118 function array_methods:append(array) | 118 function array_methods:append(ina) |
119 local len, len2 = #self, #array; | 119 local len, len2 = #self, #ina; |
120 for i = 1, len2 do | 120 for i = 1, len2 do |
121 self[len+i] = array[i]; | 121 self[len+i] = ina[i]; |
122 end | 122 end |
123 return self; | 123 return self; |
124 end | 124 end |
125 | 125 |
126 function array_methods:push(x) | 126 function array_methods:push(x) |