Compare three variables?
#1

Hi,

In an if statement you can do something like:
if(Variable1 == Variable2)
{
blabla
}

But is this also posible with three variables, something like:
if(variable1 == variable2 == variable3)

?
Reply
#2

if(variable1 == variable2 && variable2 == variable3)
this should work because if var1 = to var2, it checks if var2 equals to var3///
Reply
#3

Why would you want to do that? It's exactly the same as doing if(variable1 == variable3)



Perhaps you mean 'is variable 1 equal to variable 2 OR variable 3'? In which case:

if(var1 == var2 || var1 == var3)
Reply
#4

Nah he had it right... he's trying to check if all three variables are equal.

EDIT: Yes Paul... I was talking about you when I said 'he got it right'...
Reply
#5

if(variable1 == variable2 && variable2 == variable3)
...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)