Skip to content

Instantly share code, notes, and snippets.

@mnem
Created March 19, 2010 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mnem/337512 to your computer and use it in GitHub Desktop.
Save mnem/337512 to your computer and use it in GitHub Desktop.
// 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