From: Robin Stocker Date: 2006-10-12T05:23:16+09:00 Subject: Re: case ... when and arrays (or what was why_ showing us at railsconf europe) J2M wrote: > Hi, > > I would like to test a string foo against an array bar in as case... > when clause and would like to know the best way to do this. I am sure > why_ did something neat with an * operator, but can't find any > reference. I could do it long hand, but that just aint rubyish. > > e.g. > > foo = "that" > bar = %(this that other) You don't have an array in bar, just a string. You need to use %w: bar = %w(this that other) > case foo > > when (some clever way of test for foo in the array bar) when *bar which corresponds to: when "this", "that", "other" > . > . > else > > end > > Anybody got a good suggestion? Cheers, Robin