C
Chris Morris
I just threw down the following -- it smells like I'm over-complicating
matters here. Is there a more elegant to do this?
if (user.nil_or_empty?) && (!pswd.nil_or_empty?)
raise 'cannot specify pswd without specifying user'
end
class String
def nil_or_empty?
empty?
end
end
class NilClass
def nil_or_empty?
nil?
end
end
I wanted to avoid this:
if (user.nil? || user.empty?) && !(pswd.nil? || pswd.empty?)
...which I guess isn't that bad now that I read it, although
nil_or_empty? will come in handy if I need to re-use it a lot.
--
Chris
http://clabs.org/blogki
-=-=-=-=-=-=-=-=-=-=-=-=-=-
Free solo piano album (mp3)
http://cministries.org/cstudios/blackandwhite.htm
matters here. Is there a more elegant to do this?
if (user.nil_or_empty?) && (!pswd.nil_or_empty?)
raise 'cannot specify pswd without specifying user'
end
class String
def nil_or_empty?
empty?
end
end
class NilClass
def nil_or_empty?
nil?
end
end
I wanted to avoid this:
if (user.nil? || user.empty?) && !(pswd.nil? || pswd.empty?)
...which I guess isn't that bad now that I read it, although
nil_or_empty? will come in handy if I need to re-use it a lot.
--
Chris
http://clabs.org/blogki
-=-=-=-=-=-=-=-=-=-=-=-=-=-
Free solo piano album (mp3)
http://cministries.org/cstudios/blackandwhite.htm