Skip to content
BENIBIX Learn

Null

Development🧩 Programming ConceptsData and Variables

Also known as None, nil, Null Value

A special value meaning no value at all. It is not zero or empty text.

Think of it like

Think of it like an empty seat with a name card. The seat is there, but nobody is in it.

Example

A form leaves middle_name as None when Jack has no middle name. The page then skips that line.

Why it matters

Real data is full of gaps. Null lets a program say "unknown" instead of making up a value.

Definition

Null is a special value that means nothing is here. A variable can exist and still hold no real value yet. Python calls it None, Go and Ruby call it nil, and many others call it null. It is different from zero or an empty string, which are real values. Using a null as if it held something is one of the commonest crashes in code.

Example code

python
>>> middle_name = None
>>> middle_name is None
True
The name exists, but there is nothing in it yet.

Common mistake

Forgetting to check for null before using a value. The program then crashes on the one empty case.

Key takeaways

  1. 1
    Means nothing. Not zero, not empty text, just no value.
  2. 2
    Many names. null, None and nil are the same idea.
  3. 3
    Check first. Test for it before you use the value.

Learn it properly