From: Phlip Date: 2008-08-24T02:01:00+09:00 Subject: Why 'if 0' succeeds in Ruby Rubiods: One of the first "gotchas" here coming from another language is 0 is not like 'true'. This Daily WTF (which I think someone just posted here) illustrates the problem which Ruby solves: http://thedailywtf.com/Articles/pider-Detection.aspx "Rather than check the difference between 0 and FALSE (or use a more appropriate function), the original developer just dropped the first letter of each crawler name so that strpos doesn't return 0." $spider_footprint = array('ooglebot', 'rawler', 'pider', 'ulliver', 'arvest', 'ahoo! Slurp'); foreach($spider_footprint as $spider_name) { if (strpos($agent, $spider_name)) { $is_spider = 1; ... The problem is not that the programmer did not want to add FALSE != . The problem is that language treats 0 as false, when 0 positively means we have a good value with a 0 inside it. 0 as FALSE is a legacy of languages that could not distinguish 0 and NULL. So the Ruby version would work like: if agent.index('googlebot') So, once again, Ruby gives us the right defaults, precedents, and operations that do much more, with much less code. -- Phlip