I have a list of five strings. I want to see if the variable passed in is equal to any of these five strings. Is there a better way than doing an if/else or case statement?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming I understand what you mean, here’s an ugly, but simple to understand method, and we put the strings in to a list: