"%s"-format template function arguments

vladdeSV v at vladde.net
Sun Apr 15 12:04:19 UTC 2018


Hello people of D-land.

In a template function, I want to format all arguments as if it 
was an array. Se this snippet of code:

     foo(1,2,3);

     void foo(T...)(T args)
     {
         writefln("expected: %s", [1,2,3]);
         writefln("actual: %s", args);
     }

The code above will output

     expected: [1, 2, 3]
     actual: 1

How would I go on about to print all the arguments as I expected 
it, using "%s"?

Best regards,
Vladimirs Nordholm

---

P.S.
I do not understand why only a `1` is printed in the actual 
result.


More information about the Digitalmars-d-learn mailing list