From: gregarican Date: 2007-01-06T02:10:05+09:00 Subject: Re: case when... Personally I like to adopt the old Smalltalk philosophy, where they don't even use case statements. Since over time these can grow long and ungainly you can take a different programming approach. It's a bit of a mind stretch depending on where you're coming from, but it is good practice. I think there's an older book called Smalltalk Best Practice Patterns that touches on this. A good read, even if you don't ever write a lick of Smalltalk. It's solid OOP approaches you can apply to Ruby and other OOP languages. Jacob Fugal wrote: > On 1/5/07, Josselin wrote: > > >> case 'a' > > >> when 'a1' > > >> puts.. > > >> puts ... > > >> return > > >> when 'a2' > > >> puts ... > > >> puts ... > > >> puts ... > > >> return > > >> when 'a3' then puts ... > > >> else > > >> puts ... > > >> puts ... > > >> end > > > > a return was missing to close the latest 'else'.... > > Huh? You don't need returns to "close" the when's or else. Unlike C, > there's no "trickle" effect to Ruby case statements, one a branch has > been matched, only that branch is executed. There's no need for > "break" or "return" or anything like that. > > Jacob Fugal