lineSplitter ignores the the trailing newline?

Paul Backus snarwin at gmail.com
Sat Nov 9 19:28:52 UTC 2019


On Saturday, 9 November 2019 at 19:00:31 UTC, Jonathan Marler 
wrote:
> In people's opinion, should lineSplitter handle files with 
> trailing newlines differently or the same?  Currently, 
> lineSplitter will ignore the trailing newline.  If it didn't 
> ignore it, then I'd expect that a file with a trailing newline 
> would return an empty string as its last element, but it 
> doesn't do this.

lineSplitter follows the Unix convention of treating newlines as 
line *terminators* rather than line *separators* (as we can see 
from the name of its template argument "KeepTerminator"). Under 
this convention, a trailing newline terminates the final line in 
a file, but does not start a new one, so there is no need for an 
additional empty line.


More information about the Digitalmars-d mailing list