[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: what's wrong with this loop syntax?
- From: Bret Victor <bret@...>
- Date: Mon, 8 Jan 2007 22:24:53 +0000 (UTC)
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.