Skip to content

Instantly share code, notes, and snippets.

@v1993
Created April 3, 2016 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save v1993/37ca51fef42eaa63b30eeb585f67c84a to your computer and use it in GitHub Desktop.
Save v1993/37ca51fef42eaa63b30eeb585f67c84a to your computer and use it in GitHub Desktop.
Small lua code to read file using for with iterator
readiter = function(h, size)
return function()
return h:read(size)
end;
end;
--[[
Using: for var in readiter(fileh, size) do your_code end
size -- one of supported formats to file:read()
file -- vaule getted using io.open(filename, 'r') -- read mode required!
]]--
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment