Created
November 19, 2014 03:50
-
-
Save jbodah/7b456fc975382ddb3ffe to your computer and use it in GitHub Desktop.
reattach method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):001:0> receiver = Object.new | |
=> #<Object:0x007fc4a1939320> | |
irb(main):002:0> original = receiver.method(:to_s) | |
=> #<Method: Object(Kernel)#to_s> | |
irb(main):003:0> original == receiver.method(:to_s) | |
=> true | |
irb(main):004:0> receiver.define_singleton_method(:to_s, original) | |
=> :to_s | |
irb(main):005:0> original == receiver.method(:to_s) | |
=> false | |
irb(main):006:0> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment