[Issue 2114] New: Incorrect example foreach readLine()

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue May 20 09:08:43 PDT 2008


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

           Summary: Incorrect example foreach readLine()
           Product: D
           Version: 2.014
          Platform: PC
               URL: std_stream.html
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: www.digitalmars.com
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: jlquinn at optonline.net


InputStream.opApply docs offer the following example:

 Stream file = new BufferedFile("sample.txt");
 foreach(ulong n, string line; file) {
   stdout.writefln("line %d: %s",n,line);
 }
 file.close();

This is seductively simple and desirable but doesn't compile, since line is
invariant and readLine() returns char[].  Either docs need to be fixed to use
char[] or the method needs to return a string.


-- 



More information about the Digitalmars-d-bugs mailing list