This post originated from an RSS feed registered with PHP Buzz
by Joe Grossberg.
Original Post: Query Methods in Rails and true/false
Feed Title: Joe Grossberg
Feed URL: http://feeds.feedburner.com/joegrossbergatom/
Feed Description: My bullshit, your brain.
So this has its own set of rules: false and nil still evaluate to false, but so do 0 and an empty string. However, empty arrays, empty hashes and the 0.0 float evaluate to true.
For [] and {}, you can do foo.empty?. But for 0.0, you have to do foo.zero?.
Ugh; more arbitrary stuff to memorize (or test in the console).
I wish there was some method that combined ?, empty? and zero?. Perhaps there is one that I've overlooked?