Skip to main content

Command Palette

Search for a command to run...

Boolean checks should not be inverted

Published
1 min read
Boolean checks should not be inverted
S

I love learning about technology and sharing that with others

it is needless to invert the result of boolean comparison instead of that we should made the opposite comparison.

Noncompliant Code Example

if ( !(a == 2)) { ...}  // Noncompliant
boolean b = !(i < 10);  // Noncompliant

Compliant Solution

if (a != 2) { ...}
boolean b = (i >= 10);
9 views

More from this blog

H

hashcodehub

271 posts

Consistent, Passionate and Organized :)