Skip to content

Instantly share code, notes, and snippets.

@jonleighton
Created September 20, 2011 15:55
Show Gist options
  • Save jonleighton/1229485 to your computer and use it in GitHub Desktop.
Save jonleighton/1229485 to your computer and use it in GitHub Desktop.
class A
def foo
"<3"
end
end
class B < A
def foo
# super will still call A#foo, even after the method is aliased
super * 2
end
alias :old_foo :foo
def foo
"o_O"
end
end
puts A.new.foo # => <3
puts B.new.old_foo # => <3<3
puts B.new.foo # => o_O
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment