From: Jason Roelofs Date: 2008-08-24T02:41:03+09:00 Subject: Re: Why 'if 0' succeeds in Ruby On Sat, Aug 23, 2008 at 1:31 PM, Dave Bass wrote: > But unfortunately Ruby regards both false and nil as not-true. For some > reason, this is touted as a feature. > > False and nil are two quite different concepts and should not be > conflated. > -- > Posted via http://www.ruby-forum.com/. > > It's a perfectly fine feature and makes perfect sense if you understand Ruby's object model. 0 is not nothing, it's Fixnum(0). Thus it's an object, and not anything that can be differentiated from, say 2, 5 or "some string". Of course nil is NilClass and false is FalseClass, which are also objects, but there needs to be something that allows for if(false) checks, so those two classes are the special cases. When taken as in context of Ruby as a whole, this of course makes sense, as nil is effectively our nothing (like NULL / 0 in C and C++) and FalseClass is our actual 'false'. Jason