On 1/26/11 6:24 PM, spir wrote:
On 01/26/2011 10:21 PM, Steven Schveighoffer wrote:
On Wed, 26 Jan 2011 16:13:41 -0500, Trass3r <[email protected]> wrote:
(readln only uses ~= on buf, it doesn't change the original string)
What? Why does it take a ref argument then? If it doesn't overwrite the
buffer passed in, there is no point in giving it a buffer.
No I meant it doesn't alter buf's original content, i.e. "hello"
Of course it modifies the array itself via ~= and thus takes it as a
ref.
Though it should use 'out' instead I think.
Then why not return the newly-created buffer? Why alter the buffer via a
parameter? It makes no sense to me.
Better API:
char[] readln();
or if you want different char types:
C[] readln(C = char)();
Yes, that's how I think readln's API should be. Is a buf version for
repeated use? (I guess no, since input comes from a user?)
Denis
There is an overload of readln that looks like that.
Andrei