I was wondering if there was a shorter way to write
if (test != 'e' || test != 'd')
I want to write it like
if (test != ('e' || 'd'))
Or something like this so i don’t have to repeat “test !=”
Thanks
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.
That’s the syntax of the language. There’s not much you can do about it… If you don’t like the way it looks, you can make a boolean function that contains the tests and then just call that function:
EDIT: There are other ways to write this code (see the comments to this answer), but your original way is probably the cleanest approach.