extending nil methods

has anyone done something like this?

class NilClass   def empty?; true; end   def strip; nil; end   def (s); nil; end end

which is nice so that you can do this without throwing exception: if !params[:something].empty? if !params[:something][:else].strip.empty?

as opposed to this: if params[:something] && !params[:something].empty? if params[:something] && params[:something][:else] && ! params[:something][:else].strip.empty?

It seems to work fine for me so far. I'm just wondering what's the negative effect of doing that? If not then shouldn't we be doing this :slight_smile: ?

- reynard

ah I knew there must be a better way. It's strange that I cannot find blank? in the ruby or rails api documentation. Thanks a lot, - reynard