Created
March 19, 2010 13:50
-
-
Save mnem/337512 to your computer and use it in GitHub Desktop.
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
// This is just one of the reasons why | |
// treating null as a boolean false | |
// is Bad and Wrong | |
var iAmAStringInstance :String = ""; | |
var iAmANullString :String = null; | |
if(iAmAStringInstance) | |
{ | |
trace("iAmAStringInstance: That there is an instance!"); | |
} | |
else | |
{ | |
trace("iAmAStringInstance: That there is a null object!"); | |
} | |
if(iAmANullString) | |
{ | |
trace("iAmANullString: That there is an instance!"); | |
} | |
else | |
{ | |
trace("iAmANullString: That there is a null object!"); | |
} | |
// Trace outputs: | |
// | |
// iAmAStringInstance: That there is a null object! | |
// iAmANullString: That there is a null object! | |
// | |
// As I said, both Bad and Wrong ;) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment