Created
June 8, 2019 08:22
-
-
Save ldemailly/c3afe1630d41a35627d2cf4e11487e2c to your computer and use it in GitHub Desktop.
OO tables
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
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