lua-users home
lua-l archive

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


Michael Newberry wrote:
Is there any way to make it more compact (and more readable to me, at least), where the loop is tested at the top of the loop? Here is what I use:

   while true do
       str = S:Next()
       if str == nil then break end
       -- [code]
   end

local function strings(S)
  return function() return S:Next() end
end

for str in strings(S) do
  -- [code]
end

--
Shmuel