On Monday, 3 December 2018 at 06:09:21 UTC, Joel wrote:
I can't seem to get this to work!

```
foreach(line; File("help.txt").byLine) {
    writeln(line.stripLeft);
```

With the code above, I get this compile error:
source/app.d(360,36): Error: template std.algorithm.mutation.stripLeft cannot deduce function from argument types !()(char[]), candidates are:
/usr/local/opt/dmd/include/dlang/dmd/std/algorithm/mutation.d(2602,7):        
std.algorithm.mutation.stripLeft(Range, E)(Range range, E element) if 
(isInputRange!Range && is(typeof(range.front == element) : bool))
/usr/local/opt/dmd/include/dlang/dmd/std/algorithm/mutation.d(2610,7):        
std.algorithm.mutation.stripLeft(alias pred, Range)(Range range) if (isInputRange!Range 
&& is(typeof(pred(range.front)) : bool))

I just want to use each 'line' variable as a string?! I've tried 'byLineCopy', and 'line.to!string'. I've looked at documentation.

https://run.dlang.io/is/h0ArAB

works for me. If you want it as a string not char[] then byLineCopy should work, if not just `.idup` `line`.

Reply via email to