From: Pit Capitain Date: 2004-05-20T09:27:27+09:00 Subject: Re: Zero is true ... whoda thunk? Booker C. Bense wrote: > _ I think this issue is a Licorice Test[1] for Ruby. To me it's > fundamental to the entire point of Ruby. If you are really > bothered by this, then maybe Ruby is not for you. For me, its > one of the big reasons I really like Ruby. A Ruby in which > zero was false would not be Ruby.... Agreed. Boolean values are used for what? To test a condition. A normal condition like "x > 0" or "s.empty?" has a value of true or false. I think there's no discussion about this. Besides those normal conditions Ruby has a shortcut for exactly one special case: "did I get a valid result from a method call or not?" In Ruby, this translates to "did I get a real object or nil?" (Of course nil is an object as everything else in Ruby, but it has the meaning of "no object".) You could code this condition as if !x.nil? or unless x.nil? but since it is so common, Ruby has the shortcut if x From this point of view, only nil can be treated as false. Regards, Pit