p method in Ruby hard to search for

前端 未结 4 1068
自闭症患者
自闭症患者 2021-01-17 12:30

I\'m trying to find info on the p method in Ruby. It seems to produce internal info on the properties of a class but when I try to search for it I get every wor

4条回答
  •  孤城傲影
    2021-01-17 13:16

    You can find more information about the p method from the Ruby documentation of the Kernel module:
    http://www.ruby-doc.org/core/Kernel.html#method-i-p

    p(obj) → obj

    p(obj1, obj2, ...) → [obj, ...]

    p() → nil

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

    S = Struct.new(:name, :state)
    s = S['dave', 'TX']
    p s
    

    produces:

    #
    

提交回复
热议问题