From: Tim Pease Date: 2007-06-21T04:40:34+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. > PhotoEndings = %w(JPG MRW JPE) MovieEndings = %w(AVI) case ext.upcase when *PhotoEndings puts "I'm a photo!" when *MovieEndings puts "I'm a movie!" else puts "I'm unknown '#{ext}'" end When you were declaring your endings with the %w notation, you had put commas between the file extensions. Therefore, your arrays only contained one element. Give this code a shot. You almost had it -- the syntax you were looking for was the leading splat "*" in front of the PhotoEndings and MovieEndings in the branches of the case statement. Blessings, TwP