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 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 .. $])
{
    ranges ~= File(filename, "r").byLineCopy;
}
```

Reply via email to