Skip to content

Instantly share code, notes, and snippets.

@sionide21
Created August 12, 2014 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sionide21/c4b5628d665ec962fbea to your computer and use it in GitHub Desktop.
Save sionide21/c4b5628d665ec962fbea to your computer and use it in GitHub Desktop.
The dangers of `alias` in ruby
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