From: Rob Biedenharn Date: 2008-08-21T06:41:06+09:00 Subject: Re: "num in [1,2,3,4]" in a cool way? On Aug 20, 2008, at 5:32 PM, Iņaki Baz Castillo wrote: > Hi, AFAIK in Ruby the only (or the "coolest") way to do something as: > > if num in [1,2,3,4] > > is by doing: > > if [1,2,3,4].index(num) > > Is it? any other "cooler" way? Thanks. > > -- > Iņaki Baz Castillo if [1,2,3,4].include?(num) if (1..4) === num Robert might chime in with an inject version, so I won't do one of those. -Rob Rob Biedenharn http://agileconsultingllc.com Rob@AgileConsultingLLC.com