[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: pairs(t, skey) and ipairs(t, skey)
- From: Coda Highland <chighland@...>
- Date: Wed, 2 Oct 2013 14:31:29 -0700
On Wed, Oct 2, 2013 at 2:27 PM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
>> Another habit we should not be practicing is thinking of Lua tables as having
>> array and hash parts.
>
> Exactly. This is an implementation detail for getting performance and reduced
> memory usage but Lua tables remain what they are: associative arrays.
>
> You don't even need to use #t if you keep track of how many items t has
> in some other way.
In a more generic sense, I have to ask: Is there a specific reason why
there isn't a way to determine how many keys are in a table at all?
Equivalently, why isn't there a way to know in advance how many
results pairs() will return?
/s/ Adam
- References:
- pairs(t, skey) and ipairs(t, skey), Andrew Starks
- Re: pairs(t, skey) and ipairs(t, skey), Luiz Henrique de Figueiredo
- Re: pairs(t, skey) and ipairs(t, skey), Tom N Harris
- Re: pairs(t, skey) and ipairs(t, skey), Luiz Henrique de Figueiredo