Diff

util/array.lua @ 9487:4e38121a349d

util.array: Add freeze metamethod
author Kim Alvefur <zash@zash.se>
date Fri, 12 Oct 2018 00:51:52 +0200
parent 8521:6f5ce0f09f40
child 9528:1af7cc3b9747
line wrap: on
line diff
--- a/util/array.lua	Fri Oct 12 00:15:08 2018 +0200
+++ b/util/array.lua	Fri Oct 12 00:51:52 2018 +0200
@@ -21,6 +21,8 @@
 local array_methods = {};
 local array_mt = { __index = array_methods, __name = "array", __tostring = function (self) return "{"..self:concat(", ").."}"; end };
 
+function array_mt:__freeze() return self; end
+
 local function new_array(self, t, _s, _var)
 	if type(t) == "function" then -- Assume iterator
 		t = self.collect(t, _s, _var);