Mercurial > prosody-hg
comparison util/array.lua @ 13138:0b0cefce6e42 0.12
util.array: Expose new() on module table
For consistency with other utils.
Consistency is good.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 10 Jun 2023 12:14:12 +0200 |
| parents | 3ae6fa901a8b |
| children | 451cb119026e 1bb4aa803b32 |
comparison
equal
deleted
inserted
replaced
| 13121:332e95f75dbb | 13138:0b0cefce6e42 |
|---|---|
| 32 if type(t) == "function" then -- Assume iterator | 32 if type(t) == "function" then -- Assume iterator |
| 33 t = self.collect(t, _s, _var); | 33 t = self.collect(t, _s, _var); |
| 34 end | 34 end |
| 35 return setmetatable(t or {}, array_mt); | 35 return setmetatable(t or {}, array_mt); |
| 36 end | 36 end |
| 37 | |
| 38 array.new = new_array; | |
| 37 | 39 |
| 38 function array_mt.__add(a1, a2) | 40 function array_mt.__add(a1, a2) |
| 39 local res = new_array(); | 41 local res = new_array(); |
| 40 return res:append(a1):append(a2); | 42 return res:append(a1):append(a2); |
| 41 end | 43 end |
