I am learning Ruby & Perl has this very convenient module called Data::Dumper, which allows you to recursively analyze a data structure (like hash) & allow you to print it. This is very useful while debugging. Is there some thing similar for Ruby?
相关问题
- How to specify memcache server to Rack::Session::M
- Why am I getting a “C compiler cannot create execu
- reference to a method?
- ruby 1.9 wrong file encoding on windows
- gem cleanup shows error: Unable to uninstall bundl
相关文章
- Ruby using wrong version of openssl
- Difference between Thread#run and Thread#wakeup?
- how to call a active record named scope with a str
- “No explicit conversion of Symbol into String” for
- Segmentation fault with ruby 2.0.0p247 leading to
- How to detect if an element exists in Watir
- uninitialized constant Mysql2::Client::SECURE_CONN
- ruby - simplify string multiply concatenation
Look into pp
example:
there is also the inspect method which also works quite nicely
you can use Marshal, amarshal, YAML
I normally use a YAML dump if I need to quickly check something.
In
irb
the syntax is simplyy obj_to_inspect
. In a normal Ruby app, you may need to add arequire 'YAML'
to the file, not sure.Here is an example in
irb
:The final
=> nil
just means the method didn't return anything. It has nothing to do with your data structure.