Created
May 21, 2021 16:17
-
-
Save tjdevries/15b9a413b463f950b36f596675080a5f 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
local properties = { | |
showing = { | |
get = function(t) | |
print("Yoooo we're showing.") | |
return 5 | |
end, | |
set = function(t, v) | |
error("This can't be ser.") | |
end, | |
} | |
} | |
local lookup = {} | |
local cls = setmetatable({}, { | |
__index = function(t, k) | |
if properties[k] then | |
return properties[k].get(t) | |
end | |
return lookup[k] | |
end, | |
__newindex = function(t, k, v) | |
if properties[k] then | |
return properties[k].set(t, v) | |
end | |
lookup[k] = v | |
end | |
}) | |
print(cls.showing) | |
cls.example = true | |
print(cls.example) | |
cls.showing = 7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment