Is there equivalent for PHP's print_r in Ruby / Rails?

前端 未结 8 756
鱼传尺愫
鱼传尺愫 2020-12-08 03:17

In PHP you can do:

print_r($var) or vardump($var)

which prints \"human-readible\" information about variable.

Is there equ

8条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 03:28

    Try using pp. You will need to require it in scripts (or in irb if your .irbc doesn't already do this):

    require 'pp'
    

    Then you can 'PrettyPrint' an object thus:

    pp object
    

提交回复
热议问题