Skip to content

Instantly share code, notes, and snippets.

@telent
Created December 23, 2011 12:17
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 telent/1514041 to your computer and use it in GitHub Desktop.
Save telent/1514041 to your computer and use it in GitHub Desktop.
fun with method aliases
irb(main):025:0> class Foo; def foo; 42 ;end ; alias :bar :foo ;end
=> nil
irb(main):026:0> Foo.instance_method(:foo)
=> #<UnboundMethod: Foo#foo>
irb(main):027:0> Foo.instance_method(:bar)
=> #<UnboundMethod: Foo#foo>
irb(main):028:0> Foo.instance_method(:foo).name
=> :foo
irb(main):029:0> Foo.instance_method(:bar).name
=> :bar
irb(main):030:0> Foo.instance_method(:bar) == Foo.instance_method(:foo)
=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment