Skip to content

Instantly share code, notes, and snippets.

View Steelsouls's full-sized avatar
🤯
Awakening

Brandon Rubin Steelsouls

🤯
Awakening
View GitHub Profile

true and false vs. "truthy" and "falsey" (or "falsy")

by Jesse Farmer

Many programming languages, including Ruby, have native boolean (true and false) data types. In Ruby they're called true and false. In Python, for example, they're written as True and False.

But oftentimes we want to use a non-boolean value (integers, strings, arrays, etc.) in a boolean context (if statement, &&, ||, etc.). So someone designing a language has to decide what values count as "true" and what count as "false." A non-boolean value that counts as true is called "truthy," and a non-boolean value that counts as false is called "falsey."