From: Bertram Scharpf Date: 2009-07-17T05:59:48+09:00 Subject: Re: case statement puzzle Hi, Am Freitag, 17. Jul 2009, 02:12:27 +0900 schrieb Tom Cloyd: > James Coglan wrote: >> 2009/7/16 Tom Cloyd >>> >>> x='1' >>> case >>> when x =='0' >>> puts '0' >>> when (1..5).include? x.to_i >>> puts '1' >>> end >> >> What about: >> >> x='1' >> case >> when x =='0' >> puts '0' >> when '1'..'5' >> puts '1' >> end >> > THANKS! That's the "missing piece" - I need to study up on "===", about > which I know nothing. This will output "1" because the Range object '1'..'5' is not nil and not false. It has nothing to do with the === operator. You could also write x='1' case when x == '0' puts '0' when "hi, there" puts '1' end To apply the === operator you have to mention the variable after the "case" keyword. x = '1' case x when '0' then puts '0' when '1'..'5' then puts '1' end Bertram -- Bertram Scharpf Stuttgart, Deutschland/Germany http://www.bertram-scharpf.de