int a = 10;
int b = 10;
int c = 10;
I am trying to find out if there is alternate way to compare if three ints or anything are equal.
The way i am currently doing is
if( (a == b) && (a == c) && (b == c)){
}
I was wondering if there is an alternate and more concise way to do this.
Equality is transitive; you don't need the last comparison b == c
. If a == b
and a == c
, then b == c
.
Try
if ((a == b) && (a == c)){
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With