On Thu, Aug 21, 2008 at 6:41 AM, Rob Biedenharn <Rob / agileconsultingllc.com> wrote: > 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. num = 5 [*1..4].inject(num){|m,v| m == true ? m : (m == v || m) } == true But it's far from cool, and my name isn't Robert, but i hope it wakes up the competitive spirit of all injectionalisits. ^ manveru