Last active
May 21, 2016 08:44
-
-
Save YanhaoYang/8419d994b8b47f84cc6556cbc3b3ec31 to your computer and use it in GitHub Desktop.
Redefine a method by opening the class
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
class A | |
def hi | |
puts 'hi' | |
end | |
end | |
a = A.new | |
a.hi | |
# => "hi" | |
class A | |
def hi | |
puts 'hi redefined' | |
end | |
end | |
a.hi | |
# => "hi redefined" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment