Fandom

Programmer's Wiki

Null

406pages on
this wiki
Add New Page
Talk2 Share

null (often NULL, or nil) is a constant used in many programming languages to indicate that the expected value is unknown. It is different from 0, the empty string, and false because these are known to be empty.

In some programming languages, myvar==null will always produce false (or an unpredictable result), because a non-value cannot be compared with a value. Some support the syntax "myvar is null", while others have special functions like isNull() and sometimes isNotNull().

Some languages differentiate null variables from undefined ones, while others initialize all variables as null.

In the lower languages (e.g. C, C++), NULL is not an ordinary value but a pointer (some languages implement this as a pointer with a value equal to zero); this is only true "under the hood" in others.

Some languages, such as Python (None) and Lua, implement null as a first-class value. In these languages, it is a specific and individual data type.

ExamplesEdit

The following examples are in pseudocode.

myvar = null

if myvar is null {
    print "I'm sad because myvar is null"
}

if myvar is not null {
    print "I'm happy because myvar is NOT null"
}

See alsoEdit

Null Object

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.