[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Case statment not working with strings

Mike Mike

8/2/2008 9:26:00 PM


Hello, I have a rather simple case statement:

case event['event_title']
when ('Class GroupsPhoto Day' || 'Retake Day' || 'School Group' ||
'Photo' || 'Staff Group Photo' || 'Staff Group Photo' || 'Teams and
Clubs' || 'Group Photo Session')
blah...
end


the thing stored in event['event_title'] is a string and the values do
match my strings (ie should evaluate to true), but the case is never
evaluating to true.

any help appreciated, I could always use a big ugle if/elsif
--
Posted via http://www.ruby-....

2 Answers

Farrel Lifson

8/2/2008 9:30:00 PM

0

2008/8/2 Mike Mike <mike@onepipe.ca>:
>
> Hello, I have a rather simple case statement:
>
> case event['event_title']
> when ('Class GroupsPhoto Day' || 'Retake Day' || 'School Group' ||
> 'Photo' || 'Staff Group Photo' || 'Staff Group Photo' || 'Teams and
> Clubs' || 'Group Photo Session')
> blah...
> end

Use a ',' instead of '||'

Farrel
--
Aimred - Ruby Development and Consulting
http://www....

Marc Heiler

8/2/2008 10:01:00 PM

0

Mike Mike wrote:
> Thanks, also had to remove the parens

Your code also got rid of a few chars! I like it whenever in Ruby I
successfully apply the rule "less is more" to achieve the same. :-)
--
Posted via http://www.ruby-....