On Saturday, 3 August 2013 at 15:10:20 UTC, Ali Çehreli wrote:
On 08/03/2013 07:58 AM, bearophile wrote:

> Gabi:
>
>>   //HOW TO pass F1(..) the args we were called with ?
>
>
> import std.stdio;
>
> void f1(Args...)(Args args) {
>      foreach (arg; args)
>          arg.writeln;

Would you expect the following two lines behave the same?

    writeln(args);
    writefln("%s", args);

I wouldn't.

Apparently not:

10hello1.5
10

Why?

writeln simply prints all the args it receives, then a line break.

writefln, on the other end, only prints its single "fmt" arg. The rest of the args are only used as they are referenced in fmt. Your code basically boils down to:

writefln("%s", 10, "hello", 1.5);
=> 10

Reply via email to