Null is a value used to represent the intentional absence of an object or value.

Different languages use different names for this idea:

  • null in JavaScript and Java
  • nil in Go, Ruby, and Lua
  • None in Python

Null is useful when a value may be absent, but it can also introduce bugs when code assumes a value is present.

Common null-related errors include:

  • Dereferencing a null pointer
  • Calling a method on a null object
  • Forgetting to handle the absent case

Some languages use optional types to make the possibility of absence explicit in the type system.

Anki

id: null-definition deck: Computer Science::Data Types tags: data-types null

Q: What is null? A: Null is a value used to represent the intentional absence of an object or value.

id: null-common-errors deck: Computer Science::Data Types tags: data-types null errors

Q: What are common null-related errors? A: Common null-related errors include dereferencing a null pointer, calling a method on a null object, or forgetting to handle the absent case.