Case statment not working with strings

M

Mike Mike

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
 
F

Farrel Lifson

2008/8/2 Mike Mike said:
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
 
M

Marc Heiler

Mike said:
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. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top