From: "Ara.T.Howard" Date: 2004-02-20T20:20:32+09:00 Subject: Re: proposal: let kind_of take more arguments On Thu, 19 Feb 2004, Robert Klemme wrote: > Date: Thu, 19 Feb 2004 15:43:05 +0100 > From: Robert Klemme > Newsgroups: comp.lang.ruby > Subject: Re: proposal: let kind_of take more arguments > > > "Simon Strandgaard" schrieb im Newsbeitrag > news:pan.2004.02.19.14.25.27.611885@adslhome.dk... > > It just hit me.. why not let kind_of? take more arguments? > > > > irb(main):001:0> x = 3 > > => 3 > > irb(main):002:0> x.kind_of?(String) > > => false > > irb(main):003:0> x.kind_of?(String, Fixnum) > > ArgumentError: wrong number of arguments(2 for 1) > > from (irb):3:in `kind_of?' > > from (irb):3 > > irb(main):004:0> > > > > > > > > For instance I have > > > > def push(choice) > > if choice.kind_of?(Zero) == false and choice.kind_of?(One) == false > > Never compare boolean values to get boolean values. This can lead to > hideous bugs if the method at hand does not return "true" or "false" - > especially with languages that have more than one value for either. what do you reccomend (when a case won't do) ? .... unless choice.kind_of?(Zero) or choice.kind_of?(One) .... -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328 | URL :: http://www.ngdc.noaa.gov/stp/ | TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done ===============================================================================