On Saturday, 24 April 2021 at 22:13:45 UTC, Ali Çehreli wrote:
On 4/24/21 7:46 AM, PinDPlugga wrote:
...
As a general solution, you can use a function like this:

auto readLine(S = string)(File file = stdin) {
  while (!file.eof) {
    auto line = file.readln!S.strip;
    if (!line.empty) {
      return line;
    }
  }

  return null;
}

Ali

Hi Ali,

Being a new D learner, I've noticed this behavior as well. Thank you for providing the 'readLine' function! Would it be considered poor coding style to intercept the stream between readf and readln with the following statement? :

```d
     auto catcher = readln.strip;
```
P.S. I love your book on D! :)

Cheers,

Gary Chike

Reply via email to