-4

ruby newbie here.

The Data::Dumper->Dump(object) method in perl is awesome. It logs the entire structure of any object into stdout. Makes it really easy to debug. Basically looking for a method which can print the structure of any object irrespective of its type.

Is there a similar library/method in ruby?

tadman
  • 208,517
  • 23
  • 234
  • 262
user674669
  • 10,681
  • 15
  • 72
  • 105
  • 2
    https://stackoverflow.com/q/2159426/2864740 , https://stackoverflow.com/q/18292538/2864740 – user2864740 Mar 20 '20 at 21:19
  • Does this answer your question? [Ruby equivalent of Perl Data::Dumper](https://stackoverflow.com/questions/2159426/ruby-equivalent-of-perl-datadumper) – pjs Mar 20 '20 at 23:49

1 Answers1

2

Ruby has two such methods for debugging: p and pp.

The p(x) method is equivalent to:

puts x.inspect

The pp method is similar but pretty. That is it gives a more human-readable output.

tadman
  • 208,517
  • 23
  • 234
  • 262