[Issue 9599] New: File.byLine doesn't function properly with take

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 26 23:46:17 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9599

           Summary: File.byLine doesn't function properly with take
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: zshazz at gmail.com


--- Comment #0 from Chris Cain <zshazz at gmail.com> 2013-02-26 23:46:15 PST ---
Using 2.062, Regarding the following code:

---
import std.stdio, std.range;

void main() {
    auto file = File.tmpfile();
    file.write("1\n2\n3\n");
    file.rewind();

    auto fbl = file.byLine();
    foreach(line; fbl.take(1)) writeln(line);
    foreach(line; fbl) writeln(line);
}
---

The expected output for this would be:
---
1
2
3

---

but actual output:
---
1
3

---

Generalized observation: When take is used on a ByLine range, it takes the
appropriate number of elements and then consumes one additional element
preventing anything else from using it.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list