Ahh the differences between the various nulls that all kind of typedef to 0. Mainly we have them as a convention to denote certain things.
Java
null - a reserved constant that denotes a pointer to a void object
Internally represented as zero. However, you do not compare an int to this.
Javascript
undefined - object hasn't even been assigned yet
null - it is assigned and its value is null (nothing)
if you compare the two, you'll get that they are equal to each other, but they are separate concepts and if you want to find out if a variable is undefined, don't compare it to null.
C
NULL - (void *)0, to be used with pointers
You cannot use this with ints, you might get an error.
C++
NULL - 0
Can be used with pointers and ints. Signifies pointer not pointing to anything.
Objective-C
nil - to be used with object (id) to indicate 'no value'.
Nil - to be used with class pointer to indicate or point the Objective C class to 'no value'.
NSNull - a way of representing nil/null. Where you cannot pass null or use a null value, use this non-null class to represent a null value.
No comments:
Post a Comment