[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua next version
- From: Doug Currie <doug.currie@...>
- Date: Wed, 24 Jun 2009 12:12:26 -0400
On Jun 24, 2009, at 10:19 AM, John Hind wrote:
In my opinion (for what little it is worth) it would be useful if
the Lua core kept a count of the total number of elements in a
table. Then it could compare the "array count" with the "true count".
What does this buy you?
Assuming you mean "true count" is the number of non-nil table entries,
and "array count" is the result of the # operator, if they are equal
you still don't know what you have:
> t = {}
> t[1] = 1
> t[3] = 3
> t[999] = 999
> =#t
1
> t[2] = 2
> =#t
3
> t[1] = nil
> return #t
3
> i = 0
> for _,_ in pairs(t) do i = i + 1 end
> =i
3
e
- References:
- Lua next version, bb
- Re: Lua next version, Peter Cawley
- Re: Lua next version, bb
- Re: Lua next version, Miles Bader
- Re: Lua next version, Eduardo Ochs
- Re: Lua next version, bb
- Re: Lua next version, David Given
- Re: Lua next version, Luiz Henrique de Figueiredo
- Re: Lua next version, Cosmin Apreutesei
- RE: Lua next version, John Hind