Created
February 7, 2012 22:04
-
-
Save jnraine/1762393 to your computer and use it in GitHub Desktop.
Using strings as booleans in Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* The ugly way */ | |
String isSomething = "true" | |
if ( "true".equals(isSomething) ) { | |
/* It takes me a couple seconds to figure out why I'm here */ | |
} | |
/* The easy-to-read way */ | |
String isSomething = true | |
if ( isSomething ) { | |
/* I know exactly why I'm here */ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment