Can you read the next line while iterating over byLine?
John Doe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Feb 2 10:18:13 PST 2017
Let's say you're trying to parse a file format like:
Name
http://example.com
123234
Foo Bar
http://dlang.org
888888
with blocks separated by varying amount of blank lines.
-----
import std.stdio;
void main(string[] args){
auto range = File("text.txt").byLine();
foreach( line; range ){
if (line != ""){
writeln(line);
// char[] url = range.???
// char[] num = range.???
}
}
}
-----
How can you read the next line while iterating over a file line
by line, so that the next iteration uses the line after next? If
this isn't possible byLine is a design flaw and D should instead
provide a regular readLine function.
btw: What is this? A forum for a programming language that
doesn't support code blocks?
More information about the Digitalmars-d-learn
mailing list