lua-users home
lua-l archive

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


On 30/01/2008, Hans Hagen <pragma@wxs.nl> wrote:
> in the original post there was a for i=1,n loop

That's exactly because I didn't want to go into the (usually) tricky
business of changing a table while using an iterator over it. :)


> when using (i)pairs one should be real carefull with such 'created
> holes'; the same is true for 0/1 based indexed tables
>
> (lucky us that in most realistic cases things are quite intuitive)

I think what you were demonstrating is that ipairs follows the Lua
convention for arrays, which start at index 1 and goes (quote from
manual) "up to the first integer key absent from the table"... And
"absent" in this case also excludes any "remembered keys", as also
evidenced by your script. This is well-defined and well-documented
though.