From: Jeremy Henty Date: 2002-09-05T09:05:46+09:00 Subject: Re: Breaking from 'case' In article <20020905005626.A15456@profa.box.cz>, Wejn wrote: > while run > case x > when 'b' > ``skip'' if cond # how ???? > something_else > else > something > end > timer = Time.now > end > > Is there any possibility (in the example above) to skip the rest > of "when 'b'" and continue at the line "timer = Time.now" using some > keyword/statement? My first impulse would be to wrap the case in a method and skip by calling return, ie.: def munge(x) case x when 'b' return something_else else something end end while run munge x timer = Time.now end *But* that tends not to refactor nicely: if you take code that implements its control structure with return and factor some of it out into a new method, then that new method may return to the wrong place. If that is a fatal objection, or if you want to do it all inline, my next impulse would be to use catch/throw, ie: while run catch :skip do case x when 'b' throw :skip if cond # how ????, like this !!!! something_else else something end end timer = Time.now end HTH, Jeremy Henty