Created
April 3, 2016 13:18
-
-
Save v1993/37ca51fef42eaa63b30eeb585f67c84a to your computer and use it in GitHub Desktop.
Small lua code to read file using for with iterator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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