Skip to content

Instantly share code, notes, and snippets.

@bullfight
Created April 19, 2013 17:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bullfight/5421811 to your computer and use it in GitHub Desktop.
Save bullfight/5421811 to your computer and use it in GitHub Desktop.
class Foo
end
foo = Foo.new
=> #<Foo:0x007fca7132adc8>
foo.inspect
=> "#<Foo:0x007fca7132adc8>"
foo.to_s
=> "#<Foo:0x007fca7132adc8>"
class Bar
def inspect
self
end
end
bar = Bar.new
=> #<Bar:0x007fca71315068>
1.9.3p194 :015 > bar.inspect
=> #<Bar:0x007fca71315068>
1.9.3p194 :016 > bar.to_s
=> "#<Bar:0x007fca71315068>"
class Baz
attr_reader :arbitrary
def initialize
@arbitrary = ['arbitrary', 'array']
end
def inspect
arbitrary
end
def to_s
"Baz(arbitrary:#{arbitrary})"
end
end
baz = Baz.new
=> ["arbitrary", "array"]
1.9.3p194 :034 > baz.inspect
=> ["arbitrary", "array"]
1.9.3p194 :035 > baz.to_s
=> "Baz(arbitrary:[\"arbitrary\", \"array\"])"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment