I'd always assumed that alias_method(new, existing) was equivalent to something like the following (plus support for passing arguments and a block along):
def new
existing
endBut no, apparently it really does just give you another name with which you can refer to the same method body. Thus:
class Foo
def foo
"in foo"
end
alias_method :bar, :foo
undef_method :foo
end
Foo.new.barWorks fine, producing "in foo".
How convenient! I can actually rename a method. (Note: I'm not saying that renaming methods willy-nilly is advisable…)