From: Robert Klemme Date: 2004-02-20T20:21:09+09:00 Subject: Re: proposal: let kind_of take more arguments "Ara.T.Howard" schrieb im Newsbeitrag news:Pine.LNX.4.44.0402190818210.8086-100000@fattire.ngdc.noaa.gov... > 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) > ... Exactly. Boolean operators are for transformation of boolean values. Comparison with 'true', 'false', 'nil' or whatever is not appropriate for the stated reasons. :-) robert