Maybe I can generalize this into a rule: if either of operands 2 or 3

to the ternary operator are boolean constants, don't use the ternary operator.

a ? true : x   ==  a || x
a ? x : true   ==  !a || x
a ? false : x  ==  !a && x
a ? x : false  ==  a && x
This commit is contained in:
Ray Greenwell
2010-07-05 21:32:28 +00:00
parent f2f995766b
commit a5fee01354
@@ -54,8 +54,7 @@ public class TransformTest extends TestBase
} }
@Override public boolean equals (Object other) { @Override public boolean equals (Object other) {
return !(other instanceof CustomType) ? false : return (other instanceof CustomType) && value.equals(((CustomType)other).value);
value.equals(((CustomType)other).value);
} }
@Override public int hashCode () { @Override public int hashCode () {