Thread: Debunking null
View Single Post
  #5  
Old 01-24-2011, 09:19 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by MrOmega View Post
I found it strange though that null can equal -1 and 0.
null should never be -1, that was the type of null that was -1.

Quote:
Originally Posted by MrOmega View Post
But setting actual variable to those can be confused with null, thus furthering the complication.
Yes, and this is fairly common, such as...
PHP Code:
function onCreated() {
  
temp.this.someFunction(0);
}
function 
someFunction(temp.i) {
  if (
temp.== 1) {
    return 
"yeay!";
  }

This will result in temp.a sometimes being set to an empty value, meaning it will have the same behavior as what I outlined in my post.

Quote:
Originally Posted by MrOmega View Post
I prefer using the '!' (Not) before a var to check to see if it is indeed null. Null is full of lulz but it can be irritating cause of the flawz. z.z
Seems like a poor way to check if something is null since it would also be true for anything which can be coerced to the integer 0.
I think using x.type() == -1 is the best way to check if a variable doesn't exist (or if the return type of a function is null/non-existent).
Reply With Quote