From: James Coglan Date: 2009-07-17T04:26:42+09:00 Subject: Re: case statement puzzle --001636c923d7a25d1d046ed7a637 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 2009/7/16 Rick DeNatale > On Thu, Jul 16, 2009 at 12:55 PM, James Coglan > wrote: > > What about: > > > > x='1' > > case > > when x =='0' > > puts '0' > > when '1'..'5' > > puts '1' > > end > > Almost, that second when will ALWAYS match. > > Better to use the form of case which takes a value > > %w{0 1 2}.each do |x| > case x > when '0' > puts "it's like nothing, man!" > when '1'..'5' > puts "it's in there" > end > end > > it's like nothing, man! > it's in there > it's in there Whoops, I wasn't reading closely enough, just focused on the failing when clause. Thanks for the correction. --001636c923d7a25d1d046ed7a637--