X file:lines

From GiderosMobile
Revision as of 14:32, 13 July 2023 by Hgy29 (talk | contribs) (Text replacement - "<source" to "<syntaxhighlight")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Available since: Gideros 2011.6
Class: file

Description

Returns an iterator function that, each time it is called, returns a new line from the file. <syntaxhighlight lang="lua"> (function) = file:lines() </source>

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 <syntaxhighlight lang="lua"> for line in file:lines() do --body end </source>