Snookerman

03-24-2010, 09:45 AM

I have an if statement with three possible matches and depending on those matches, I want to do something. The code looks like this:

if (result1 == result2 & result2 == result3){

points = result1 + result2 + result3;

} else if (result1 == result2 || result1 == result3 || result2 == result3){

//points should equal the sum of the match

}

If all three results are a match, the points should be the sum of them, however, if only two are a match, only the sum of those two should be the points. I know I could just use three if statements for the last part, but I'm just curious if it's possible to just use one.

if (result1 == result2 & result2 == result3){

points = result1 + result2 + result3;

} else if (result1 == result2 || result1 == result3 || result2 == result3){

//points should equal the sum of the match

}

If all three results are a match, the points should be the sum of them, however, if only two are a match, only the sum of those two should be the points. I know I could just use three if statements for the last part, but I'm just curious if it's possible to just use one.