Is there a way to make the output of inspect more readable?
In Perl, there is Data::Dumper
which makes the output more easy to read.
The ruby standard library contains PP (short for "Pretty Print"), which formats structures much better than the standard inspect:
http://www.ruby-doc.org/stdlib/libdoc/pp/rdoc/index.html
You need to require 'pp'
at the top of your source file before you can use it, and then just replace p obj
with pp obj
in your code.
I find it really useful for hashes and arrays in particular!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With