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

后端 未结 9 2265
谎友^
谎友^ 2020-12-12 10:09

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

9条回答
  •  粉色の甜心
    2020-12-12 10:52

    I came across this thread because I was looking for something similar. I like the responses and they gave me some ideas so I tested the .to_hash method and worked really well for the use case too. soo:

    object.to_hash

提交回复
热议问题