lua-users home
lua-l archive

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


Shmuel Zeigerman <shmuz <at> actcom.co.il> writes:

> local function strings(S)
>    return function() return S:Next() end
> end
> 
> for str in strings(S) do
>    -- [code]
> end

Or better yet:

  for str in S.Next, S do
     -- [code]
  end

This assumes that the function S.Next doesn't change during
the iteration, which is a pretty safe bet.