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

后端 未结 9 2259
谎友^
谎友^ 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:51

    p object
    

    Ruby doc for p.

    p(*args) public

    For each object, directly writes obj.inspect followed by a newline to the program’s standard output.

提交回复
热议问题