Comparison

util/array.lua @ 13247:1bb4aa803b32 0.12

util.array: Fix new() library function Backport of ffe4adbd2af9 since new was added in the 0.12 branch
author Kim Alvefur <zash@zash.se>
date Sat, 22 Jul 2023 16:31:05 +0200
parent 13138:0b0cefce6e42
child 13248:db433ed3135c
comparison
equal deleted inserted replaced
13219:22763b30e458 13247:1bb4aa803b32
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 37
38 array.new = new_array; 38 function array.new(t)
39 return setmetatable(t or {}, array_mt);
40 end
39 41
40 function array_mt.__add(a1, a2) 42 function array_mt.__add(a1, a2)
41 local res = new_array(); 43 local res = new_array();
42 return res:append(a1):append(a2); 44 return res:append(a1):append(a2);
43 end 45 end