Skip to content

Instantly share code, notes, and snippets.

@ldemailly
Created June 8, 2019 08:22
Show Gist options
  • Save ldemailly/c3afe1630d41a35627d2cf4e11487e2c to your computer and use it in GitHub Desktop.
Save ldemailly/c3afe1630d41a35627d2cf4e11487e2c to your computer and use it in GitHub Desktop.
OO tables
function newTable(t)
if not t then
t = {}
end
setmetatable(t, {__index = table})
return t
end
t = newTable({k1="v1", k2="v2", k3="v3",})
function table:keys()
k = newTable()
for key in pairs(self) do
k:insert(key)
end
return k
end
print(t:keys():concat(" "))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment