From: Robert Klemme Date: 2010-03-31T18:19:47+09:00 Subject: Re: Pop Quiz: aliasing versus wrapping 2010/3/31 Phrogz : > 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. > > $ cat alias.rb >  class Object >    alias_method :to_js, :inspect >  end This one always invokes Object#inspect - unless you override #to_js explicitly. > $ cat wrapped.rb >  class Object >    def to_js; inspect; end >  end This is the one you really want IMHO: #to_js delegates to whatever #inspect is present in the class. Pretty straightforward inheritance behavior - although I'd concede that it's subtle. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/