On Jan 2, 2011, at 11:10 PM, timr wrote:

> Hi Gary,
> But you can add singleton methods to nil and true, so the problem with
> adding singleton methods to Fixnum objects is not related to the fact
> that they have a predetermined object_id.

Well since there is only one instance of NilClass, TrueClass, and FalseClass (nil, true, false) you can implement 'singleton' methods by simply adding a plain old instance method to the class.  So in these particular cases there is an efficient way to implement the singleton methods.

In fact:

ruby-1.9.2-p0 > nil.singleton_class
 => NilClass 
ruby-1.9.2-p0 > true.singleton_class
 => TrueClass 
ruby-1.9.2-p0 > false.singleton_class
 => FalseClass 

Gary Wright