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
7
votes
3 answers

How can you write a conditional based on the definedness of multiple variables?

Every now and then I find myself needing to write conditionals with two or three branches: at minimum, one for when all of two or more variables are defined and one for when any or none of those are defined. Sometimes that last branch needs to be…
Kaiepi
  • 3,230
  • 7
  • 27
7
votes
4 answers

Design choice: Do I want extension methods to throw exceptions on null?

Possible Duplicate: C#: Best practice for validating “this” argument in extension methods I'm ambivalent about a design choice, and would like to hear the opinions of the SO community. The example I bring up here is just one possible case where…
Tomas Aschan
  • 58,548
  • 56
  • 243
  • 402
7
votes
4 answers

Sorting IComparable objects some of which are null

Most people, when writing a refence type (class) which implements IComparable, use the convention that null is LESS than any actual object. But if you try to use the opposite convention, something interesting happens: using System; using…
JeppeSN
  • 73
  • 1
  • 3
7
votes
2 answers

MVC Model is null in OnExecuted action filter ... or a more elegant way to set the model?

I have an ActionFilter with an override on the OnActionExecuted method. The filterContext.Controller.ViewData.Model is always null on a POST operation. I did find the following article that seems to be saying that it should not be null but this must…
Mike
  • 1,405
  • 1
  • 17
  • 27
7
votes
1 answer

WindowInsets.getDisplayCutout is NULL everywhere except within onAttachedToWindow in fullscreen Java app

I am having issues with getDisplayCutout() in my fullscreen Java app. I can only seem to get the value of the DisplayCutout within the onAttachedToWindow function. After that function completes, I can never get it again. Code to get the…
Lilbug
  • 171
  • 1
  • 10
7
votes
4 answers

Nullsafe navigation in c#

Possible Duplicates: Safe Navigation Operator in C#? Shortcut for “null if object is null, or object.member if object is not null” in my XML processing project, i have to navigate through chained property to get the desired value. e.g,…
Nirmit Shah
  • 758
  • 4
  • 10
7
votes
3 answers

Get value of registry key C#

I have already looked at existing topics, so please try to refrain from dropping links here. I want to get the value of a registry key - plain and simple. Here is what I have so far. Registry: 1) Made a key under…
user725913
7
votes
3 answers

Is it safe to assume that the NULL constant is zero?

The book Understanding and Using C Pointers, by Richard Reese says: The null concept is an abstraction supported by the null pointer constant. This constant may or may not be a constant zero. A C programmer need not be concerned with their…
the_endian
  • 2,259
  • 1
  • 24
  • 49
7
votes
6 answers

Javascript Sorting Nulls Wrong In HTML Table

I'm using the below JavaScript code to sort my tables alphabetically and numerical. However, it puts rows with null values at the top instead of the bottom. In the below image, taken from this URL I am working on, when sorting the table from biggest…
Electron
  • 969
  • 1
  • 8
  • 22
7
votes
1 answer

toString but only if not null

Is there any utility available to easily get the string representation of an arbitrary object if it exists and keep it null if it was null? For example String result = null; if (object != null) { result = object.toString(); } but less…
awgtek
  • 1,483
  • 16
  • 28
7
votes
1 answer

Quicksight not showing months with no data (null?)

My visual's x-axis is Date, aggregated by month, and the y-axis is total sales (sum of costs). For some months, I had no sales, but Quicksight ignores these and only shows me the months that do have data in them, even though I want the exact number…
7
votes
1 answer

nw_dictionary_copy called with null dictionary

Swift 5, Xcode 10 Xcode is logging a weird error that's only happening when I'm doing something really specific: My app connects to an FTP server after clicking on the "login" button but if there's no internet connection, it displays a dialog with…
Neph
  • 1,823
  • 2
  • 31
  • 69
7
votes
1 answer

Groovy remove null elements from a map

I am getting a map in my method from another server and I have some null values, I wanted to remove those ones, because I am struggling with those values in the following process: My map looks something like: I had done the next code, but without…
rasilvap
  • 1,771
  • 3
  • 31
  • 70
7
votes
0 answers

Are there 2 kinds of $null in PowerShell?

I've stumbled across an odd situation in PowerShell 5.1 (Windows 10) where ConvertTo-Json produces {} instead of null for an apparently null valued object: [CmdletBinding()] param() function main() { $foo1 = $null Write-Verbose ("foo1 null?…
Marc
  • 13,011
  • 11
  • 78
  • 98
7
votes
5 answers

Is passing null in to a method acceptable

Null is an odd data type for me, it seems as though it is wrong to ever use, maybe its the null pointer errors i got so often as a beginner that now have me associating any instance of null to some kind of evil! Anyway my question is in some cases…
ricki
  • 149
  • 1
  • 3
  • 10