What are the Falsy values in Ruby?
Sarah Oconnor
Updated on May 03, 2026
In Ruby only false and nil are falsey. Everything else is truthy (yes, even 0 is truthy).
| Value | Truthy? |
|---|---|
| nil | no |
| 6.7 | yes |
| true | yes |
| TRUE | yes |
What are Falsy values?
A falsy (sometimes written falsey) value is a value that is considered false when encountered in a Boolean context. JavaScript uses type conversion to coerce any value to a Boolean in contexts that require it, such as conditionals and loops.
Is 0 A Falsy value in Ruby?
No it’s not. 🙂 Zero is a value, and ALL values in Ruby are evaluated to true, EXCEPT for FALSE and NIL.
Which of the following is a Falsy value?
A falsy value is something which evaluates to FALSE, for instance when checking a variable. There are only six falsey values in JavaScript: undefined , null , NaN , 0 , “” (empty string), and false of course.
What are Falsy values in Python?
Falsy values are values that evaluate to False in a boolean context. Falsy values include empty sequences (lists, tuples, strings, dictionaries, sets), zero in every numeric type, None , and False .
Is empty string Falsy in Ruby?
Q: An empty string ( “” ) returns true in a conditional expression! It’s very simple: in Ruby, only nil and false are false in conditional contexts. You can use empty? , compare the string to “” , or compare the string’s size or length to 0 to find out if a string is empty.
What are truthy and Falsy values?
Truthy values are values that evaluate to True in a boolean context. Falsy values are values that evaluate to False in a boolean context. Falsy values include empty sequences (lists, tuples, strings, dictionaries, sets), zero in every numeric type, None , and False .
Is an empty array Falsy Ruby?
As a developer mainly working in PHP my first instinct was simply to evaluate the array as a boolean (empty arrays are false-y in PHP). However I quickly learned that similar to JavaScript, empty arrays are truth-y in Ruby… As such, doing something like this won’t work…
What is truthy and Falsy values?
Is NaN truthy or Falsy?
In JavaScript, a truthy value is a value that is considered true when encountered in a Boolean context. All values are truthy unless they are defined as falsy (i.e., except for false , 0 , -0 , 0n , “” , null , undefined , and NaN ).
Why are there no false values in Ruby?
That means the people who built Ruby had to decide what is truthy and what is falsey. Different languages make different decisions. In Ruby only false and nil are falsey. Everything else is truthy (yes, even 0 is truthy).
How do you evaluate non-boolean values in Ruby?
Ruby, like many programming languages, has a boolean (true/false) data type. In Ruby we write “true” and “false.”. For convenience, though, we often want to evaluate non-boolean values (integers, strings, etc.) in a boolean context (if, &&, ||, etc.). Ruby has to decide whether these values count as true or false.
What does == mean in Ruby?
Keep in mind that == in Ruby is also a method, this means that the behavior can change depending on how this method is implemented. What is a truthy value? It’s a value that’s considered true in a boolean context, like an if statement.
Is Ruby a programming language or software?
Programming languages are software, too! That means the people who built Ruby had to decide what is truthy and what is falsey. Different languages make different decisions. In Ruby only false and nil are falsey. Everything else is truthy (yes, even 0 is truthy).