First of all, it is not my web mail client to blame (it has lots of its
own faults) – if your e-mail were not present in the original message
no client would be able to expose it in reply anyway ;-).
As had been mentioned many times on this list (in one form or another),
respond_to? is a lame duck of the duck typing world ;-). It only can
indicate that an object has a method in its inheritance chain to invoke
in response to a named message. I has no idea – and can’t have any,
really – what that method would do for you and even how to properly
Getting back to dup(), this method is defined for Object class, so every
Ruby object, including Fixnum instances, will inherit it. On the other
hand, there’s nothing to dup() for Fixnum – hence method redefinition
to raise a TypeError.
From: email@example.com [firstname.lastname@example.org]
Sent: Monday, January 12, 2009 23:43
To: ruby-talk ML
Subject: Re: 99.respond_to? :dup ==> true
Gennady B. wrote:
delegate to the original object, yet keeping track of all modifications.
It will work even for data types that do not support dup().
Ouch! Your web client has exposed my email id to the spammers
Anyway,… no, here i do not want the original value touched since the
user may press Escape and abandon editing.
In the case of numbers and floats, usually its a call by value so a copy
is made anyway.
Anyway, as a newbie, it was quite a surprise - i’ve relied on
respond_to? to take care of a lot of generic code.