From: Martin DeMello Date: 2010-03-31T18:30:50+09:00 Subject: Re: Pop Quiz: aliasing versus wrapping On Wed, Mar 31, 2010 at 10:01 AM, Phrogz wrote: > Below are two files that differ only in the 2nd line of code in each. > Can you guess what difference they will reveal? I must admit I was > surprised when I ran into this. It's pretty clear if you think of it in terms of message handlers and method objects >  class Object >    alias_method :to_js, :inspect >  end This binds the message handler Object#to_js to the method object Object#inspect. This should be illustrative: $ cat test.rb class Object alias_method :to_js, :inspect alias_method :inspect, :hash end a = Object.new puts a.inspect p a puts a.to_js $ ruby test.rb 67266180 67266180 # > $ cat wrapped.rb >  class Object >    def to_js; inspect; end >  end This creates a new method object, which contains a thunk that sends the message "inspect" to self when it is invoked, and binds the Object#to_js message handler to that method object. martin