[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: pairs(t, skey) and ipairs(t, skey)
- From: Paul K <paulclinger@...>
- Date: Tue, 1 Oct 2013 11:43:40 -0700
Hi Dirk,
> It is similarly nowhere guaranteed that next(t,k) equals k+1 if k+1
> happens to be a valid key, whether or not the table contains holes.
> ...
> Note in the second case, starting the iteration of the table at #t will miss
> all three non-numeric keys.
Thank you for the test case. You are correct: all my earlier tests
were false positives "confirming" incorrect assumptions. The result is
dependent on how the table is constructed (as was pointed earlier).
One of the incorrect assumptions I had was that ipairs(t) would
produce the same keys as 1..#t, but it's clearly not the case as 1..#t
may iterate over holes, but ipairs never does this (at least in Lua
5.1).
Paul.