[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Problems with: Most efficient way to recognize a line by its first three characters
- From: Petite Abeille <petite.abeille@...>
- Date: Wed, 12 Mar 2014 20:20:07 +0100
On Mar 12, 2014, at 7:49 PM, email@example.com wrote:
> while true do
> line = f:read("*line" )
> if not line then break end
Ah, also… this is more idiomatically written as:
for aLine in f:lines() do
While we are at it… there is no such format as ‘*line’ in file:read (···):
The available formats are
• "*n": reads a number; this is the only format that returns a number instead of a string.
• "*a": reads the whole file, starting at the current position. On end of file, it returns the empty string.
• "*l": reads the next line skipping the end of line, returning nil on end of file. This is the default format.
• "*L": reads the next line keeping the end of line (if present), returning nil on end of file.
• number: reads a string with up to this number of bytes, returning nil on end of file. If number is zero, it reads nothing and returns an empty string, or nil on end of file.