Is something like this ever possible?
if(a == b == c)
or is
if((a== b) && (b == c))
is the only way?
or what is the coolest way to do that?
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.
In some languages you can use that shorthand. For example in Python
a == b == cis roughly equivalent to the expressiona == b and b == c, except that b is only evaluated once.However in Java and Javascript you can’t use the short version – you have to write it as in the second example. The first example would be approximately equivalent to the following:
This is not what you want. In Java
a == b == cwon’t even compile unlesscis a boolean.