From: Mohammad Khan Date: 2004-11-02T05:34:37+09:00 Subject: Re: Another scrach on head On Mon, 2004-11-01 at 12:43, Ara.T.Howard@noaa.gov wrote: > On Tue, 2 Nov 2004, David A. Black wrote: > > > #false? might be useful to avoid lengthier tests distinguishing among > > various permutations of falsehood. I can't see too many likely uses > > for #true? > > i'd really like a #true? > > yaml = <<-txt > options: > verbose : true # or maybe 4 > txt > > config = YAML::load yaml > > options = config['options'] > > if options['verbose'].true? > @verbosity = 4 > else > @verbosity = Integer options['verbose'] > end > > now i use > > if TrueClass === options['verbose'] > @verbosity = 4 > else > @verbosity = Integer options['verbose'] > end > > which is kind of ugly. espcially where i care if it true OR false and end > doing > > # > # foobar can be a bool or a number > # > if [TrueClass, FalseClass].include? options['foobar'].class > @foobar = options['foobar'] > else > @foobar = Integer options['foobar'] > end > > > yuk! Hi Ara, You can extend Object class Object def true? return self == true ? true : false end def false? return self == false? true : false end end -- Mohammad > > cheers. > > -a > -- > =============================================================================== > | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov > | PHONE :: 303.497.6469 > | When you do something, you should burn yourself completely, like a good > | bonfire, leaving no trace of yourself. --Shunryu Suzuki > ===============================================================================