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

前端 未结 8 762
鱼传尺愫
鱼传尺愫 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:22

    One approach I lean on a lot is this:

    logger.debug "OBJECT: #{an_object.to_yaml}"
    

    Easy to read, although it can get a little unwieldy for large objects.

提交回复
热议问题