From: Phrogz Date: 2010-04-01T02:35:27+09:00 Subject: Re: Pop Quiz: aliasing versus wrapping On Mar 31, 3:19 am, Robert Klemme wrote: > 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. Yes; specifically, in this case, Object#inspect on a String calls #to_s (because it's defined), so: puts "foo".to_js #=> foo instead of the desired "foo" (with quotes).