There are no truthy values, as each type decides for itself via a .Bool
method that is called in boolean contexts. For built-in types, the following return False
when their .Bool
method is called.
0
(except Rat
of x/0
where x≠0
)
- Empty list/collection types (List, Array, Hash, Map, Set, Bag, etc)
- Empty string
Failure
Promise
prior to being kept/broken.
StrDistance
whose before/after is the same.
Junction
, when you expect it to.
- Type objects
- Nil (technically type object)
- Any undefined value (technically type objects)
Otherwise, any defined value by default returns True
when its .Bool
method is called. This includes the Str
'0'
, NaN
, and zero-length range (0^..^0
) that in other languages might not be truthy.
This answer is intended as a quick reference. See this answer for a more detailed discussion.
.Bool
method and can handle it's own truthiness. And if need be you can also use composition to handle the classic DBI case :0 but True;
– Treatment