Skip to content

Instantly share code, notes, and snippets.

@tjdevries
Created May 21, 2021 16:17
Show Gist options
  • Save tjdevries/15b9a413b463f950b36f596675080a5f to your computer and use it in GitHub Desktop.
Save tjdevries/15b9a413b463f950b36f596675080a5f to your computer and use it in GitHub Desktop.
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