On Saturday, 28 December 2013 at 17:15:17 UTC, Jakob Ovrum wrote:
On Saturday, 28 December 2013 at 16:59:51 UTC, bearophile wrote:
void main() {
   import std.stdio, std.string;
   immutable txt = readln.chomp;
   writeln(">", txt, "<");
}


Bye,
bearophile

These examples are cute, but I think in real programs it's usually important to handle `stdin` being exhausted. With `readln`, such code is prone to go into an infinite loop.

Of course in these same real programs, `byLine` is often the better choice anyway...

Usually if you're working with a console though the input stream won't exhaust and thus the blocking 'readln' would be a better option, no?

I'll just use the chomp method as that seems like the best option.

Reply via email to