Bug 2114 – Incorrect example foreach readLine()

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2008-05-20T11:08:00Z
Last change time
2014-04-23T18:27:48Z
Assigned to
nobody
Creator
jlquinn

Comments

Comment #0 by jlquinn — 2008-05-20T11:08:41Z
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.
Comment #1 by witold.baryluk+d — 2010-11-24T07:52:30Z
For reference: this bug is related to bug2081
Comment #2 by rinick — 2011-03-09T02:27:29Z
*** Issue 5724 has been marked as a duplicate of this issue. ***
Comment #3 by andrej.mitrovich — 2014-04-23T18:27:48Z
This was fixed.