Created
February 25, 2015 01:30
-
-
Save mbj/05242e51ce6d80a32f54 to your computer and use it in GitHub Desktop.
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
# original code | |
class Foo | |
def foo | |
:original | |
end | |
end | |
# reference made from original code | |
method = Foo.new.method(:foo) | |
# monkey patch | |
class Foo | |
def foo | |
:patched | |
end | |
end | |
# Reference gets evaluated | |
# Effect not visible. I'm surprised. | |
p method.call # => :original |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm not that surprised. Similar to what alias does
Which is also an interesting caveat, especially when providing "convenience" aliases for a "humane" interface.