Besides the fact that one of them is a method (and therefore evaluates its arguments like any method), you should leave the general use cases to find the difference.
For example, if you do
class Foo def old_name 'foo' end def self.rename_name alias_method :new_name, :old_name end end class Bar < Foo def new_name 'bar' end end Bar.rename_name
Then Bar overwrites its new_name method, and Foo is untouched
However, if you change this to use alias ie
class Foo def old_name 'foo' end def self.rename_name alias :new_name :old_name end end class Bar < Foo def new_name 'bar' end end Bar.rename_name
Then the Bar class does not change, and Foo gets a method called: new_name. This is not like the difference between using define_method and defining a method with def .
In one case, the scope is purely lexical: the location of the line that calls alias completely determines what happens, while in the other case it is self when ruby ββevaluates this bit of code.
source share