X file:lines: Difference between revisions
From GiderosMobile
m Text replacement - "<source" to "<syntaxhighlight" |
No edit summary |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
__NOTOC__ | __NOTOC__ | ||
'''Available since:''' Gideros 2011.6<br/> | '''Available since:''' Gideros 2011.6<br/> | ||
'''Class:''' [[ | '''Class:''' [[X File]]<br/> | ||
=== Description === | === Description === | ||
| Line 7: | Line 7: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
(function) = file:lines() | (function) = file:lines() | ||
</ | </syntaxhighlight> | ||
Unlike '''[[io.lines]]''', this function does not close the file when the loop ends. | Unlike '''[[io.lines]]''', this function does not close the file when the loop ends. | ||
| Line 20: | Line 20: | ||
--body | --body | ||
end | end | ||
</ | </syntaxhighlight> | ||
{{File}} | {{X File}} | ||
Latest revision as of 21:39, 24 January 2026
Available since: Gideros 2011.6
Class: X File
Description
Returns an iterator function that, each time it is called, returns a new line from the file.
(function) = file:lines()
Unlike io.lines, this function does not close the file when the loop ends.
Return values
Returns (function) iterator function
Example
To iterate over all lines of a file
for line in file:lines() do
--body
end