Skip to main content

nil

nil Type

Supertypes:

all types

Description:

The type nil contains no objects and so is also called the empty type. The type nil is a subtype of every type. No object is of type nil.

Notes:

The type containing the object nil is the type null, not the type nil.

Expanded Reference: nil (Type)

The Empty Type

As a type specifier, nil denotes the empty type -- no object is of type nil.

(typep nil nil)
=> NIL

(typep 42 nil)
=> NIL

(typep t nil)
=> NIL

Subtype of Everything

The nil type is a subtype of every type.

(subtypep nil 'integer)
=> T
=> T

(subtypep nil 'string)
=> T
=> T

(subtypep nil t)
=> T
=> T

Coercing to nil Always Fails

(handler-case (coerce 42 nil)
(type-error () "type-error signaled"))
=> "type-error signaled"