From: Frederick Cheung Date: 2008-08-21T10:23:32+09:00 Subject: Re: "num in [1,2,3,4]" in a cool way? On 20 Aug 2008, at 22:32, 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. Well not saying this is actually a good idea, but... class Object def in(collection) collection.include? self end end if num.in [1,2,3,4] ... end