Quiz

Posted by Tom on 2007-08-25

This neat hack just popped into my head – something I’ve wanted for ages. But what is it for?

    class Object
      def _?()
        self
      end
    end

    class NilClass
      def _?()
        SafeNil.new
      end
    end

    class SafeNil
      def method_missing(*args, &b)
        nil.send(*args, &b) rescue nil
      end
    end


(edit)