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

Calling methods on a null reference in the context of a using clause is OK?

I was looking at the mvc-mini-profiler designed by the Stack Overflow team on Google Code and one thing on the getting started page struck me as particularly strange: var profiler = MiniProfiler.Current; // it's ok if this is null using…
Jake Petroules
  • 23,472
  • 35
  • 144
  • 225
8
votes
2 answers

In PowerShell, why is $null -lt 0 = $true? Is that reliable?

Consider the following PowerShell code: > $null -gt 0 False > $null -ge 0 False > $null -eq 0 False > $null -le 0 True > $null -lt 0 True Of course the same is true for a $variable explicitly set to $null or for a non-existent variable. Why is…
mmseng
  • 735
  • 9
  • 24
8
votes
2 answers

How can I pass a null value for date in vb.net to sql stored procedure?

My application is asp.net with vb. In my page I have a textbox for passing date. If I didn't enter date and on clicking submit, I have to pass null value to the stored procedure. I tried following codes such as DBNull.Value and DateTime.MinValue.…
Nandini
  • 393
  • 4
  • 15
  • 37
8
votes
7 answers

[NSNull isEqualToString:]

Im trying to set a string to "No Display name if [object objectForKey@"display_name"] is NULL". It crashing with this in the log 2011-06-16 10:58:36.251 BV API[15586:ef03] displayNameType is: NSNull 2011-06-16 10:58:36.251 BV API[15586:ef03]…
Sam Baumgarten
  • 2,231
  • 3
  • 21
  • 46
8
votes
4 answers

NULL in instantiation

When writing C++, let's assume the following line of code: Object* obj = new Object(); If this line both compiles and does not cause exceptions or any other visible runtime problems, can obj be NULL right after this line was executed?
user181218
  • 1,655
  • 5
  • 28
  • 42
8
votes
1 answer

Handling null references when using eg Linq-To-Xml

Is there a better/shorter way to handle (lots of) null references, for example when I'm using LinqToXML. I wrote this extention for XElement that handles it quite nicely, but maybe there is another way? And what about the function name? "And"…
Ward Werbrouck
  • 1,442
  • 18
  • 32
8
votes
2 answers

Is it valid to pass the address of a non-array variable to a function parameter declared as `Type ptr[static 1]`?

As mentioned here, here and here a function (in c99 or newer) defined this way void func(int ptr[static 1]){ //do something with ptr, knowing that ptr != NULL } has one parameter (ptr) of type pointer to int and the compiler can assume that the…
T S
  • 1,656
  • 18
  • 26
8
votes
6 answers

Java - Get/set methods receiving and returning "null"

I'm a beginner in Java. I'm trying, for training purpose, to build myself a chess game application. Within my class Case, that will be used to instanciate all the 64 cases of my board, I write get/set methods to find if there's a Piece occupant in…
AntoineG
  • 1,237
  • 4
  • 15
  • 25
8
votes
1 answer

ConnectivityManager getActiveNetworkInfo() is always null even with data traffic active

i'm working on a android project and i had the need to check for internet connection. i searched the web and i found a solution here on stackoverflow. However, i'm having problems on checking the internet state. I already searched everywhere but i…
8
votes
1 answer

What is the difference between a null pointer constant (nullptr), a null pointer value and a null member pointer value?

In ISO/IEC 14882:2017 (C++17), Section 5.13.7 "Pointer literals" is stated: 5.13.7 Pointer literals [lex.nullptr] pointer-literal: nullptr 1 The pointer literal is the keyword nullptr. It is a prvalue of type std::nullptr_t. [Note: std::nullptr_t…
8
votes
8 answers

Handle null parameters while calling a method using Reflection

I'm trying to write code that will infer types from a parameter list and then call the method that matches those parameters. This works very well, except when the parameter list has a null value in it. I am wondering how I might cause the…
palswim
  • 11,856
  • 6
  • 53
  • 77
8
votes
7 answers

Intervals: How can I make sure there is just one row with a null value in a timstamp column in table?

I have a table with a column which contains a 'valid until' Date and I want to make sure that this can only be set to null in a single row within the table. Is there an easy way to do this? My table looks like this (postgres): CREATE TABLE…
mojoo-de
  • 501
  • 5
  • 20
8
votes
6 answers

Local constant initialised to null reference

I have read that C# allows local constants to be initialised to the null reference, for example: const string MyString = null; Is there any point in doing so however? What possible uses would this have?
Andy Bowskill
  • 1,734
  • 3
  • 18
  • 36
8
votes
3 answers

Default bool to false when null in database with Entity Framework 4.1 Code First

How can I set the default value when a value (bit) in the database is set to NULL. Right now I'm getting a error telling me that it can't be NULL when loading a bool from the database. Thanks.
Andreas
  • 1,311
  • 5
  • 24
  • 39
8
votes
5 answers

Handling null in java streams with optional

What would be the best way of handling null if we have senario like below //mocking for demonstraton studentsByCourseRoster.setUsers(null); studentsByCourseRoster.getUsers().stream().forEach(user -> { final UserDTOv2 userDTO = new…
Seth De
  • 417
  • 6
  • 18