From: Rick DeNatale Date: 2007-06-21T04:20:48+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. > > Thanks. I hope I have explained this. I have no idea what to search for. > I did try some, but I'm a newbie and don't understand the more advanced > syntax. > > I tried > when PhotoEndings.any > and > when PhotoEndings.or > case when PhotoEndings.include?(ext) .... when MovieEndings.include?(ext) ... end The form case x when y #do something when z #do something else end ... is actually equivalent to: if y === x then #do something elsif z === x # do something else end and case #no value when y # do something when z # do something else end if y then #do something elsif z # do something else end -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/