Software /
code /
prosody
Comparison
util/array.lua @ 8521:6f5ce0f09f40
util.array: Add a __name field to metatable
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 16 Feb 2018 08:23:15 +0100 |
parent | 8017:ec7cab8e744d |
child | 9487:4e38121a349d |
comparison
equal
deleted
inserted
replaced
8520:e959bc51de75 | 8521:6f5ce0f09f40 |
---|---|
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 (self) return "{"..self:concat(", ").."}"; end }; | 22 local array_mt = { __index = array_methods, __name = "array", __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 |