We know
require 'pp'
a=["value1", "value2", "value3"]
pp a
pretty prints the array as an output to the console. How do I get that pretty output into a string (a string containing the newlines that makes things pretty, etc.)?
…purpose being to return that pretty string from a method.
Best Answer
#pretty_inspect
also comes along when you first require 'pp' - See: http://ruby-doc.org/stdlib-2.1.0/libdoc/pp/rdoc/Kernel.html#method-i-pretty_inspectIf you want the version that is outputted to the
irb
console that isand doesn't have any requires necessary.