From: John Joyce Date: 2007-06-28T22:42:09+09:00 Subject: Re: pretty_print woes On Jun 28, 2007, at 8:26 AM, Ronald Fischer wrote: >>> require 'pp' >>> .... >>> result=foo(bar) >>> $my_message="The function call foo("+ >>> bar.pretty_print_inspect+ >>> ") returned: "+result.pretty_print_inspect >>> >>> This works well most of the time, for example if the values >> formatted >>> with pretty_print_inspect are arrays or numbers. I get, however, a >>> runtime error when calling for String: >>> >>> "abc".pretty_print_inspect >>> RuntimeError: pretty_print is not overridden for String >>> >>> Is there a different way to use the module pp, so that its >> output goes >>> to a string? >> irb(main):009:0> puts "foo\"bar".pretty_inspect >> "foo\"bar" >> => nil > > Thanks a lot! Nearly perfect!! (Actually, I use pretty_inspect.chomp, > because pretty_inspect adds a \n to the formatted string). > > Ronald > Actually, puts is adding that \n to the string, but your result is what you wanted!