Bug 11830 – std.stdio.byLine reports extra line if you don't call .front
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-12-27T10:19:00Z
Last change time
2014-02-09T11:41:00Z
Assigned to
nobody
Creator
peter.alexander.au
Comments
Comment #0 by peter.alexander.au — 2013-12-27T10:19:03Z
If you don't call 'front' while iterating a ByLine range, you get a different number of elements.
import std.stdio;
import std.range;
import std.algorithm;
void main()
{
File("stuff", "w").write("line 1\nline 2\n");
writeln(File("stuff").byLine.walkLength);
writeln(File("stuff").byLine.filter!"true".walkLength);
}
This prints:
3
2
This should print 2 in both cases.
Comment #1 by github-bugzilla — 2014-01-31T03:43:47Z