'pp' for D?

linkrope linkrope at github.com
Sun Sep 29 07:31:14 PDT 2013


I want to pretty-print the representation of a value of a generic 
type T.
In Ruby, I would use 'pp':

     value = 'hello'
     pp value  # prints "hello" - with quotes!
     value = 42
     pp value  # prints 42

Now, value.to!string eliminates the quotes, should value be of 
type string.
As a workaround, I put the value into an array to make use of the 
"undocumented" function formatElement:

     "%(%s%)".format([value])

Ugly! Where does Phobos hide the function I'm looking for?


More information about the Digitalmars-d-learn mailing list