From: Chad Perrin Date: 2007-02-23T12:22:31+09:00 Subject: Re: Ruby's "case" doesn't behave like a normal switch On Fri, Feb 23, 2007 at 10:55:06AM +0900, Guillaume Nargeot wrote: > > it seems you can do it with the following code: > > case x > when 1..2 > # do something > when 3 > # do some other thing > else > end > > But when it comes to strings, you would like to be able to do simply: > > case x > when "this" > when "that" > # do something common to "this" and "that" > when "nothing" > # something different > end These two examples are not equivalent. In one, you're listing multiple cases on a single line with the associated code following it. In the other, you're listing cases separately and letting the lack of a break cause it to fail over to the next -- which leads to a very unintuitive set of code. Why not just employ your list of cases for the same resulting code on one line? That works just fine. -- CCD CopyWrite Chad Perrin [ http://ccd.apotheon.org ] "The ability to quote is a serviceable substitute for wit." - W. Somerset Maugham