Skip to content

Instantly share code, notes, and snippets.

@rubiii
Forked from mattetti/singleton_methods.rb
Created November 10, 2009 18:39
Show Gist options
  • Save rubiii/231143 to your computer and use it in GitHub Desktop.
Save rubiii/231143 to your computer and use it in GitHub Desktop.
$ irb1.9
irb(main):001:0> class Foo; end
=> nil
irb(main):002:0> foo = Foo.new
=> #<Foo:0x0000010107cd38>
irb(main):003:0> def foo.bar; 'foobar'; end
=> nil
irb(main):004:0> foo.bar
=> "foobar"
irb(main):005:0> Foo.new.bar
NoMethodError: undefined method `bar' for #<Foo:0x00000101071ca8>
from (irb):5
from /usr/local/bin/irb1.9:12:in `<main>'
irb(main):006:0> foo.singleton_methods
=> [:bar]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment