From: flebber Date: 2010-11-20T05:40:34+09:00 Subject: Re: Ruby Not observing DRY principle On Nov 19, 10:01 pm, flebber wrote: > On Nov 19, 9:01 pm, Shadowfirebird wrote: > > > > > [Note:  parts of this message were removed to make it a legal post.] > > > > Can a case statement return multiple correct cases? > > > > >nope. > > > But this will, and it's no less compact than a case statement IMO: > > > wins = [] > > wins << 1 if (a > 3) > > wnis << 2 if (a > 5) > > wins << 3 if (a < 7) > > wins << 4 if (a < 3) > > > For a = 4, wins should be [1,3].   Hopefully you get the idea. > > > -- > > What a tangled web we weave / Go 'round with circumstance / Someone show me > > how to tell / The dancer from the dance... > > I like your example so I started reading. > > if for each wins in your example their was two conditions I could then > chain them together with an and. Awesome thanks. > > So following your example where wins = [1,3] ( still not sure why ruby > doesn't have a multiple case select) can I use "and" "or" > > If wins = 1 puts "for option 1 x = A_value and y = B_value" >     and or > If wins = 2 puts "for option 2 x = A_value and y = B_value" >     and or > If wins = 3 puts "for option 3 x = A_value and y = B_value" >     and or > If wins = 4 puts "for option 2 x = A_value and y = B_value" > else puts " There were no valid options" I apologise. Combination of learning and tired. I woke up in the middle of the night and went while statement or case statement. Silly me found this this morning. http://www.skorks.com/2009/08/how-a-ruby-case-statement-works-and-what-you-can-do-with-it/