Created
December 2, 2014 11:11
-
-
Save akirayu101/a808b102348185fa02ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = {} | |
a["__realdata"] = {} | |
a["__realdata"]["a"] = 1 -- save const a | |
a["__realdata"]["b"] = 2 -- save const b | |
local function const_index(o, key) return o["__realdata"][key] end | |
local function const_newindex(o, key, value) return end | |
setmetatable(a, {__index = const_index, __newindex = const_newindex}) | |
print(a["a"]) | |
print(a["b"]) | |
a["a"] = 3 | |
a["b"] = 4 | |
print(a["a"]) | |
print(a["b"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment