>>>>> "X" == Xiangrong Fang <xrfang / hotmail.com> writes:

X> irb(main):001:0> def NilClass.method_missing(m, *a)

  you have defined a singleton method for the object NilClass

X> NoMethodError: undefined method `length' for nil:NilClass

 ruby search the method #length for the object nil, it then search the
 method #method_missing for the object nil and don't find it

X> irb(main):007:0> def a.method_missing(m, *a)

 you have defined  a singleton method for the object a

X> irb(main):010:0> a.hello

 ruby search the method #length for the object a, it then search the
 method #method_missing for the object a and it find it

 conclusion : define the method #method_missing for nil

   class NilClass
      def method_missing(*a)          
         nil
      end
   end



Guy Decoux