I was trying to learn about pretty_print, as that is how Pry displays objects to stdout, when I learned about this method. It is pretty simple so I will just show an example.
class MyClass
attr_accessor :long, :list, :of, :attrs
end
pp MyClass.new
#<MyClass:0xobject_id @long=nil, @list=nil, @of=nil, @attrs=nil>
class MyClass
def pretty_print_instance_variables
[:@long]
end
end
pp MyClass.new
#<MyClass:0xobject_id @long=nil>
Top comments (0)