[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Arrays with holes in
- From: George Petsagourakis <petsagouris@...>
- Date: Tue, 19 Sep 2006 10:13:46 +0000 (UTC)
>
> Any better suggestions?
>
try setting a metatable for the table,...
__newindex, should work for new indexes
__index, should work if you are accessing already existing indexes
something along the lines of :
local tT = {}
setmetatable( tT, {
__newindex = function( t, k, v )
if v == nil then
v = 'nil'
else
rawset(t, k, v )
end,
end,
__index = function( t, k)
if t[k] == nil then
return 'nil'
else
rawget(t, k)
end
end
} )
table.insert( tT, foo )
table.insert( tT, baar )
table.insert( tT, baz )
a = b(t)