27 September 2013

A Sliver of Ruby #1: Truthiness

In Ruby, there are only two values that mean "false": the literal false and nil.

Everything else is truthy; in order words, evaluates to true in boolean expressions.

This can be confusing for programmers who have experience with other languages where 0 (zero) is falsey.  Not so in Ruby.

For the excruciating details, check out this gist: https://gist.github.com/jfarmer/2647362

No comments:

Post a Comment