From: "Ara.T.Howard" Date: 2004-02-20T20:20:39+09:00 Subject: Re: proposal: let kind_of take more arguments On Thu, 19 Feb 2004, Simon Strandgaard wrote: > Date: Thu, 19 Feb 2004 15:25:27 +0100 > From: Simon Strandgaard > Newsgroups: comp.lang.ruby > Subject: proposal: let kind_of take more arguments > > It just hit me.. why not let kind_of? take more arguments? this is a good idea regardless of your exact situation - it reads nicer than a case, which i generally use for this -a > > 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 > raise "got #{choice.class}" > end > @choices << choice > end > > > It could turn into > > def push(choice) > unless choice.kind_of?(Zero, One) > raise "got #{choice.class}" > end > @choices << choice > end > > > -- > Simon Strandgaard > -- =============================================================================== | 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 ===============================================================================