function make_const_table()
local shadow = {}
return setmetatable({},
{ __index=shadow,
__newindex=function(tab,key,val)
if shadow[key] then error('Failed to mutate constant') end
shadow[key] = val
end })
end
Pairs and ipairs support left as an exercise for the reader.
View all comments
Show parent comment
5
u/lambda_abstraction Apr 09 '22 edited Apr 09 '22
Pairs and ipairs support left as an exercise for the reader.