Christian Neukirchen schrieb:
>>>Sometimes, I'd like an "eating nil" that returns itself for each
>>>method call, and is false.
>>>
>>>Then, stuff like that would be possible
>>>
>>>while line = gets.ignore_if_nil.chomp
>>>  ...
>>>end

Here you go:

   EATING_NIL = Object.new

   def EATING_NIL.nil?
     true
   end

   def EATING_NIL.method_missing(*)
     self
   end

   class Object
     def ignore_if_nil
       self
     end
   end

   def nil.ignore_if_nil
     EATING_NIL
   end

Regards,
Pit