From: Harold Hausman Date: 2007-06-21T04:15:39+09:00 Subject: Re: if == any item in an array On 6/20/07, 12 34 wrote: > I'd like to write something like > > PhotoEndings = %w[JPG,MRW,JPE] > MovieEndings = %w[AVI] > case ext # determined from the photo file name > when PhotoEndings > > when MovieEndings > > else > end > > I don't have to use case, any conditional will do. > I think you're looking for Array#include? $ ri Array#include? --------------------------------------------------------- Array#include? array.include?(obj) -> true or false ------------------------------------------------------------------------ Returns +true+ if the given object is present in _self_ (that is, if any object +==+ _anObject_), +false+ otherwise. a = [ "a", "b", "c" ] a.include?("b") #=> true a.include?("z") #=> false Hope that helps, -Harold