Falsy values for all programming languages

by stink on Apr 18, 2021 to before comments(0)
This is a list of falsy values for each programming language. It doesn't have every language but more will be added.

Statically typed languages that may only have one "falsy" value are listed.

Having obviously done some research on these values, I can tell you that there are a wide range of falsy values out there with some being quite odd, for instance in Game Maker any number less than 0.5 is falsy.

If you know the falsy values for a language not included or see a mistake, then let me know in the comments and I'll make an edit.

Without further ado, here's the list:

ActionScript
- false
- null
- empty string
- NaN
- 0

AppleScript
- false

Bash
- in an exit status context anything non-zero is falsy

C
- false
- 0, 0u, 0l, 0ul, 0ll, 0ull, 0.0, 0.f and 0.L
- NULL
- '\0', L'\0'

C++
- false
- 0, 0u, 0l, 0ul, 0ll, 0ull, 0.0, 0.f and 0.L
- NULL
- nullptr
- '\0', L'\0', u8'\0', u'\0' and U'\0'
- std::denorm_absent, std::ios_base::goodbit, std::ios_base::erase_event

C#
- false

Clojure
- false
- nil

CoffeeScript
- null
- false
- empty string
- undefined
- 0

Common Lisp
- nil
- empty list

Crystal
- nil
- false
- null pointer

Dart
- any value other than true

Elixir
- nil
- false

Elm
- False

Emacs Lisp
- nil
- empty list

Game Maker Language
- false
- any real number less than 0.5

Go
- false

Groovy
- false
- null
- empty string
- 0
- empty collection
- empty map
- iterators with no more elements
- matchers with no matches

Haskell
- False

Java
- false

JavaScript
- false
- 0, 0.0, 0x0, -0, -0.0, -0x0, 0n, -0n, 0x0n and -0x0n
- empty string
- null
- undefined
- NaN
- document.all

Julia
- false

Lua
- false
- nil

Perl
- undef
- 0
- empty string
- "0"
- empty list
- empty hash

PHP
- false
- 0, -0, 0.0 and -0.0
- empty string
- "0"
- empty array
- null
- SimpleXML objects that have neither children nor attributes

Python
- empty list
- empty tuple
- empty dictionary
- empty set
- empty string
- empty range
- 0, 0.0, 0j
- False
- None

R
- NULL
- FALSE
- 0L, 0, 0+0i
- empty string
- 00 one byte raw vector with zero value
- empty vector
- empty list
- an object from the try-error class

Racket
- #f

Ruby
- false
- nil

Rust
- false

Scheme
- #f
no comments yet