Skip to content

Instantly share code, notes, and snippets.

@amoeba
Created December 22, 2008 22:15
Show Gist options
  • Save amoeba/39152 to your computer and use it in GitHub Desktop.
Save amoeba/39152 to your computer and use it in GitHub Desktop.
t = {"apple", "orange"}
setmetatable(t, {
__index = function (t, i)
t[i] = "absent"
return t[i]
end
})
print(t[3]) -- => "absent"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment