Fix Issue 16991 - Make writeln documentation palatable

This commit is contained in:
Jack Stouffer 2017-02-15 11:33:45 -05:00
parent 1951dec16b
commit d7f6cc337e

View file

@ -3374,8 +3374,8 @@ private @property File trustedStdout() @trusted
} }
/*********************************** /***********************************
For each argument $(D arg) in $(D args), format the argument (as per For each argument $(D arg) in $(D args), format the argument (using
$(LINK2 std_conv.html, to!(string)(arg))) and write the resulting $(REF to, std,conv)) and write the resulting
string to $(D args[0]). A call without any arguments will fail to string to $(D args[0]). A call without any arguments will fail to
compile. compile.
@ -3383,6 +3383,23 @@ Params:
args = the items to write to `stdout` args = the items to write to `stdout`
Throws: In case of an I/O error, throws an $(D StdioException). Throws: In case of an I/O error, throws an $(D StdioException).
Example:
Reads `stdin` and writes it to `stdout` with an argument
counter.
---
import std.stdio;
void main()
{
string line;
for (size_t count = 0; (line = readln) !is null; count++)
{
write("Input ", count, ": ", line, "\n");
}
}
---
*/ */
void write(T...)(T args) if (!is(T[0] : File)) void write(T...)(T args) if (!is(T[0] : File))
{ {