Elisp: Boolean (true false nil)
Boolean in Emacs Lisp
There is no Boolean Type in elisp.
nil, 'nil
,
and empty list (list )
are false, anything else is true.
- nil is a builtin variable. Value of nil is Symbol
'nil
. - t is a builtin variable. Value of t is Symbol
't
. It is used to represent true by convention.
;; all false (if nil "true" "false") (if 'nil "true" "false") (if () "true" "false") (if '() "true" "false") (if (list) "true" "false")
By convention, t is used for true.
;; all true (if t "true" "false") (if 0 "true" "false") (if "" "true" "false") (if (vector ) "true" "false")
Boolean Functions
and
(and t nil) ; nil ;; can take multiple args (and t nil t t t t) ; nil
or
(or t nil) ; t
not
(not t) ; nil (not nil) ; t (not 2) ; nil