Created
August 12, 2014 19:40
-
-
Save sionide21/c4b5628d665ec962fbea to your computer and use it in GitHub Desktop.
The dangers of `alias` in ruby
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
class Parent | |
def foo | |
"Parent#foo" | |
end | |
alias :bar :foo | |
end | |
class Child < Parent | |
def foo | |
"Child#foo" | |
end | |
end | |
Parent.new.foo # => "Parent#foo" | |
Parent.new.bar # => "Parent#foo" | |
Child.new.foo # => "Child#foo" | |
Child.new.bar # => "Parent#foo" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment