From: "Ara.T.Howard" Date: 2005-08-10T12:11:10+09:00 Subject: Re: NEWBIE QUESTION: pattern with nil On Wed, 10 Aug 2005, basi wrote: > Hello, > I'm a bit tired typing: > > if a == "" or a == nil > if a != "" and a !== nil > > I'm sure there is a Ruby way to do this. > > Thanks for the help. > basi i generally use harp:~ > cat a.rb a = 'foobar' p 42 unless a.nil? or a.empty? a = nil p 42 unless a.nil? or a.empty? harp:~ > ruby a.rb 42 because the meaning is very clear. for shorter i use harp:~ > cat a.rb a = 'foobar' p 42 unless a.to_s.empty? a = nil p 42 unless a.to_s.empty? harp:~ > ruby a.rb 42 cheers. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | Your life dwells amoung the causes of death | Like a lamp standing in a strong breeze. --Nagarjuna ===============================================================================