lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Tue, Jan 4, 2011 at 09:07, Axel Kittenberger <axkibe@gmail.com> wrote:
>> table.insert uses the same #len operator (aux_getn to be exact) and
>> will gladly insert your new value into the first available hole.
>
> a) if by the "first available" you do not mean the lowest index
> (otherwise again someone following into this trap? :-), but the first
> showing up on binary search, then its true.
>
> b) it might or might not shift indexes after the hole:
>

I was responding to a comment by Dirk who suggested to use
table.insert to append to the end of an array.
I simply wanted to point out that table.insert(t,v) suffers from the
same problems as t[#t+1]=v

Yes, "first available hole" should be replaced by "first found hole".
It does make a difference.

--Leo--