[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Safe navigation operator
- From: Wesley Smith <wesley.hoke@...>
- Date: Mon, 23 Aug 2010 14:55:38 +0200
Is this what you're trying to do?
local meta
meta = {
__index = function(t, k)
print("__index", t, k)
if(not rawget(t, k)) then
rawset(t, k, setmetatable({}, meta))
end
return t[k]
end,
__newindex = function(t, k, v)
print("__newindex", t, k, v)
rawset(t, k, v)
end
}
-- config.network.server.url
local config = setmetatable({}, meta)
config.network.server.url = "http://www.lua.org"