Created
January 10, 2015 00:41
-
-
Save rokob/11be3b1eb4ade6321091 to your computer and use it in GitHub Desktop.
This file contains 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
module A | |
class B | |
def shit(x) | |
puts "I AM THE ORIGINAL #{x}" | |
x + 1 | |
end | |
alias_method :oops, :shit | |
end | |
end | |
a = A::B.new.shit(1) | |
b = A::B.new.oops(1) | |
module A | |
class B | |
alias_method :_old_shit, :shit | |
def shit(x) | |
puts "I AM THE NEW SHIT #{x}" | |
x + 10 | |
end | |
# alias_method :oops, :shit | |
end | |
end | |
c = A::B.new.shit(1) | |
d = A::B.new.oops(1) | |
puts "RESULTS: #{a} - #{b} - #{c} - #{d}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
With L23 commented out, it prints
RESULTS: 2 - 2 - 11 - 2
With L23 not commented out, it prints
RESULTS: 2 - 2 - 11 - 11