Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method
PP::PPMethods#pp
(::PP::_PrettyPrint obj) -> untyped
pp(obj)
lib/pp.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/pp.rb, line 200
def pp(obj)
# If obj is a Delegator then use the object being delegated to for cycle
# detection
obj = obj.__getobj__ if defined?(::Delegator) and ::Delegator === obj
if check_inspect_key(obj)
group {obj.pretty_print_cycle self}
return
end
guard_inspect(obj) do
group do
obj.pretty_print self
rescue NoMethodError
text Kernel.instance_method(:inspect).bind_call(obj)
end
end
end
Adds obj to the pretty printing buffer using Object#pretty_print or Object#pretty_print_cycle.
Object#pretty_print_cycle is used when obj is already printed, a.k.a the object reference chain has a cycle.
See also
#pop_inspect_key
#pp_hash
#object_group
#pp_hash_pair
also in
4.0 · 3.4 · 3.3 · 3.2 · 3.1 · 3.0