How do I dump an object's fields to the console?

roryf picture roryf · Dec 9, 2008 · Viewed 190.3k times · Source

When I'm running a simple Ruby script, what's the easiest way to dump an object's fields to the console?

I'm looking for something similar to PHP's print_r() that will work with arrays as well.

Answer

Christian Lescuyer picture Christian Lescuyer · Dec 10, 2008

Possibly:

puts variable.inspect