lua-users home
lua-l archive

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


2010/5/26 steve donovan <steve.j.donovan@gmail.com>:
> On Wed, May 26, 2010 at 2:52 PM, Roberto Ierusalimschy
> <roberto@inf.puc-rio.br> wrote:
>> Few (if any) benchmarks use pairs; many use numerical loops ;)
>
> For instance,
>
> for i,v in ipairs(t) do
>  if v == '' then table.remove(t,i) end
> end
>
> is rather less clear without ipairs...
>
> steve d.
>

I might be wrong, but I think this is actually buggy. Usually, you
would do it that way:
for i=#t,1,-1 do
  if v == "" then table.remove(t,i) end
end


Eike