Re: Array of byLineCopy ranges behaves as they are byLine

2019-03-11 Thread Paul Backus via Digitalmars-d-learn
On Monday, 11 March 2019 at 17:33:31 UTC, HaraldZealot wrote: Ah yes, I forget about laziness of `map`. BTW, I have found other solution, which is more fit to my initial intention. ```d ReturnType!(std.stdio.File.byLineCopy!(char, immutable(char)))[] ranges; foreach(filename; args[1 .. $]) {

Re: Array of byLineCopy ranges behaves as they are byLine

2019-03-11 Thread HaraldZealot via Digitalmars-d-learn
On Monday, 11 March 2019 at 17:04:56 UTC, ag0aep6g wrote: To avoid the re-evaluation, assign `ranges[0]` to a variable before using it: auto lines = ranges[0]; writeln(lines.front); writeln(lines.front); writeln(lines.front); That should print the same line three times. Ah

Re: Array of byLineCopy ranges behaves as they are byLine

2019-03-11 Thread ag0aep6g via Digitalmars-d-learn
On Monday, 11 March 2019 at 15:23:53 UTC, HaraldZealot wrote: ```d File[] files; foreach(filename; args[1 .. $]) { files ~= File(filename, "r"); } auto ranges = files.map!(a => a.byLineCopy); writeln(ranges[0].front); writeln(ranges[0].front); writeln(ranges[0].front); ``` produces ``` 1 2