[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Tables, Metatables, Children, and Length
- From: Marc Lepage <mlepage@...>
- Date: Tue, 4 Dec 2012 11:01:01 -0500
Thanks. I find that regular ipairs does not work, but typing this in (from PiL 7.3) does:
function iter (a, i)
i = i + 1
local v = a[i]
if v then
return i, v
end
end
function ipairs (a)
return iter, a, 0
end
I was basically hoping to store children in a metatable. Right now I'm looking at doing it in the table directly to save this hassle. But am I to understand that Lua 5.2 allows me to specify the length operator in such a way that having children in the metatable would work?