truthiness
Truthiness is an aspect of some languages in which some (usually all) non-Boolean values are valid in Boolean contexts.
Specifically, languages with truthiness allow non-Boolean values as arguments to logical operators and conditional branches.
Truthiness is a property of values. A value that is “truthy” behaves like true
in Boolean contexts; a value that is “falsy” behaves like false
in Boolean contexts.
Truthiness can be viewed as a kind of weak typing. In practice, though, it is fairly benign.
The most problematic aspect of truthiness is that it is not consistent across languages. There are two popular paradigms.
- In languages closely related to Common Lisp, there is exactly one falsy value (
nil
), and all other languages are truthy. - In languages more closely related to C, the general practice is that “empty values” are considered falsy, while all other values are considered truthy.