Questions tagged [null]

Null means *nothing* or *unknown*, depending on context. Please use the "sql-null" tag for SQL specific questions.

"Null" has different meanings depending on context.

Set theory

Null is another name for the empty set, denoted by the symbol ∅. For this reason, some programming languages use null or nil for the empty list or empty tuple. Lisp uses nil to mean the empty list and the boolean value false.

Pointers and References

Null (or sometimes nil or None), in programming languages that support it, is the value of an uninitialized variable, a pointer that doesn't point to a meaningful memory address, or an object that fails to respond to any message.

Nullable references were invented by C.A.R. Hoare in 1965 as part of the Algol W language. Hoare later described his invention as a "billion-dollar mistake".

For more information, see Null pointer.

Agreeing with Hoare's sentiment, many languages don't have a special null value, choosing to use optional types instead.

Relational Databases

NULL as a special marker in SQL or a relational database stands in place of a value that is missing, or in a join means "no corresponding row." The operators IS NULL and IS NOT NULL are required for comparisons to a literal null: other comparisons between NULL and any value evaluate to "unknown."

For more information, see Null (SQL).

ASCII

Null or NUL is the name given to the character with ASCII code zero (0) - i.e. hex 00. In some languages, notably C, NUL is used to mark the end of a character string.

For more information, see Null character.

16208 questions
129
votes
14 answers

Is null an Object?

Is null an Object in Java?
Registered User
  • 3,050
  • 5
  • 26
  • 32
129
votes
6 answers

Does std::string have a null terminator?

Will the below string contain the null terminator '\0'? std::string temp = "hello whats up";
mister
  • 3,303
  • 10
  • 31
  • 48
128
votes
7 answers

remove null or undefined from properties of a type

I need to declare a type such that removes the undefined from its property types. Suppose we have: type Type1{ prop?: number; } type Type2{ prop: number | undefined; } type Type3{ prop: number; } I need to define a generic type called…
Fartab
  • 4,725
  • 2
  • 26
  • 39
128
votes
12 answers

Why is there a `null` value in JavaScript?

In JavaScript, there are two values which basically say 'I don't exist' - undefined and null. A property to which a programmer has not assigned anything will be undefined, but in order for a property to become null, null must be explicitly assigned…
Christoph
  • 164,997
  • 36
  • 182
  • 240
128
votes
7 answers

Why does Map.of not allow null keys and values?

With Java 9, new factory methods have been introduced for the List, Set and Map interfaces. These methods allow quickly instantiating a Map object with values in one line. Now, if we consider: Map map1 = new HashMap
hi.nitish
  • 2,732
  • 2
  • 14
  • 21
127
votes
13 answers

What is a 'NoneType' object?

I'm getting this error when I run my python script: TypeError: cannot concatenate 'str' and 'NoneType' objects I'm pretty sure the 'str' means string, but I dont know what a 'NoneType' object is. My script craps out on the second line, I know the…
insecure-IT
  • 2,068
  • 4
  • 18
  • 26
126
votes
12 answers

How to do ToString for a possibly null object?

Is there a simple way of doing the following: String s = myObj == null ? "" : myObj.ToString(); I know I can do the following, but I really consider it as a hack: String s = "" + myObj; It would be great if Convert.ToString() had a proper overload…
codymanix
  • 28,510
  • 21
  • 92
  • 151
125
votes
19 answers

Null check chain vs catching NullPointerException

A web service returns a huge XML and I need to access deeply nested fields of it. For example: return wsObject.getFoo().getBar().getBaz().getInt() The problem is that getFoo(), getBar(), getBaz() may all return null. However, if I check for null in…
125
votes
32 answers

IBOutlet is nil, but it is connected in storyboard, Swift

Using Swift 1.1 and Xcode 6.2. I have a UIStoryboard containing a singular, custom UIViewController subclass. On it, I have an @IBOutlet connection of type UIView from that controller to a UIView subclass on the storyboard. I also have similar…
Stefan Arambasich
  • 2,231
  • 2
  • 19
  • 24
123
votes
2 answers

Sort by column ASC, but NULL values first?

I need to sort a PostgreSQL table ascending by a date/time field, e.g. last_updated. But that field is allowed to be empty or null and I want records with null in last_updated come before non-null last_updated. Is this possible? order by…
mhd
  • 4,561
  • 10
  • 37
  • 53
123
votes
8 answers

IN Clause with NULL or IS NULL

Postgres is the database Can I use a NULL value for a IN clause? example: SELECT * FROM tbl_name WHERE id_field IN ('value1', 'value2', 'value3', NULL) I want to limit to these four values. I have tried the above statement and it doesn't work, well…
Phill Pafford
  • 83,471
  • 91
  • 263
  • 383
122
votes
10 answers

What is the proper way to check for null values?

I love the null-coalescing operator because it makes it easy to assign a default value for nullable types. int y = x ?? -1; That's great, except if I need to do something simple with x. For instance, if I want to check Session, then I usually end…
CatDadCode
  • 58,507
  • 61
  • 212
  • 318
122
votes
12 answers

Error:null value in entry: incrementalFolder=null

I am getting following error in gradle build. Error:null value in entry: incrementalFolder=null How can I fix this?
Ishvar Kikani
  • 1,394
  • 2
  • 8
  • 13
121
votes
6 answers

When is null or undefined used in JavaScript?

I am confused as to when JavaScript returns null or undefined. Also different browsers seem to be returning these differently. I am seeking some examples of null/undefined with the browsers that return them. While I am now clear on the undefined…
copenndthagen
  • 49,230
  • 102
  • 290
  • 442
120
votes
7 answers

Redefining NULL

I'm writing C code for a system where address 0x0000 is valid and contains port I/O. Therefore, any possible bugs that access a NULL pointer will remain undetected and at the same time cause dangerous behaviour. For this reason I wish to redefine…
Lundin
  • 195,001
  • 40
  • 254
  • 396