'pp' for D?

linkrope linkrope at github.com
Sun Sep 29 15:38:43 PDT 2013


On Sunday, 29 September 2013 at 18:14:03 UTC, monarch_dodra wrote:
> On Sunday, 29 September 2013 at 14:31:15 UTC, linkrope wrote:
>> As a workaround, I put the value into an array to make use of 
>> the "undocumented" function formatElement:
>>
>>    "%(%s%)".format([value])
>
> That seems excessive. What happened to format(`"%s"`, s) or 
> format("\"%s\"", s) or text('"', s, '"')?

Of course, this works well when I know that the value is of type 
string.

But I have a template and I want to print the representation of 
(T value):
"hello" (with quotes) or just 42 (without)

Phobos does this for array elements, but it seems that there's 
nothing like 'repr'?


More information about the Digitalmars-d-learn mailing list