Skip to content

End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method

Kernel#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.

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

produces:

Example
#<S name="dave", state="TX">
See also #open #Pathname #__method__ #pp also in 4.1 · 4.0 · 3.4 · 3.3 · 3.2 · 3.0