From: Morton Goldberg Date: 2007-05-08T23:47:28+09:00 Subject: Re: Difference answers from Terminal, TextMate, and BBEdit On May 8, 2007, at 8:34 AM, Brian Candler wrote: > 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 Beg to differ with you. This is a case with no argument. It doesn't have any obj to do a 'year' === obj on. Regards, Morton