From: Brian Candler Date: 2007-05-08T21:34:22+09:00 Subject: Re: Difference answers from Terminal, TextMate, and BBEdit On Tue, May 08, 2007 at 07:22:39PM +0900, Morton Goldberg wrote: > A case statement like > > > case > when 'year' : tree.ageOneYear # , y as shortcut? > when (1..100) : tree.pick_an_orange > else puts('Don\'t be greedy, don\'t try to pick more than 100 oranges') > end > > > just looks for the first true when-clause. In this case that will > always be 'year' because everything but false and nil is true in Ruby. That's incorrect. Case doesn't check if 'year' is true; it checks whether 'year' === obj is true. Try this: foo = "Hello" case foo when "year" puts "xxx" when /ell/ puts "yyy" # this line is run end