comparison util/array.lua @ 13032:ea4923bebca9

util.array: Change tostring format to [a,b,c] Arrays in Lua do use { } but since __tostring is often user-facing it seems sensible to use [ ] instead for consistency with many other systems; as well as to allow the {a,b,c} formatting to be used by util.set without being confused with util.array.
author Kim Alvefur <zash@zash.se>
date Thu, 06 Apr 2023 16:27:37 +0200
parents d10957394a3c
children 451cb119026e
comparison
equal deleted inserted replaced
13031:1023c3faffac 13032:ea4923bebca9
22 local array_base = {}; 22 local array_base = {};
23 local array_methods = {}; 23 local array_methods = {};
24 local array_mt = { 24 local array_mt = {
25 __index = array_methods; 25 __index = array_methods;
26 __name = "array"; 26 __name = "array";
27 __tostring = function (self) return "{"..self:concat(", ").."}"; end; 27 __tostring = function (self) return "["..self:concat(", ").."]"; end;
28 }; 28 };
29 29
30 function array_mt:__freeze() return self; end 30 function array_mt:__freeze() return self; end
31 31
32 local function new_array(self, t, _s, _var) 32 local function new_array(self, t, _s, _var)