From: Issac Date: 2001-12-09T21:33:59+09:00 Subject: [ruby-talk:28023] Re: why doesn't zero evaluate to false? It'll take some getting used to but I guess I don't rely much on the falseness of zero in C++ anyway. No big deal. ----- Original Message ----- From: "Phil Tomson" Newsgroups: comp.lang.ruby To: "ruby-talk ML" ; Sent: Sunday, December 09, 2001 2:58 AM Subject: [ruby-talk:28011] Re: why doesn't zero evaluate to false? > In article <013501c1804a$45a39c10$6401a8c0@mojave>, > Issac wrote: > >Does it cost more to test whether a FixNum is zero than > >it does to test whether an object's type is NilClass or > >FalseClass? > > I don't think it was an issue of runtime cost (I could be wrong) - but > more an issue of designing the language such that the only values that > evaluate to false are false (or FalseClass objects) and nil (NilClass). > It's more an issue of consistency - 0 is a FixNum, so why should it be a > special case that evaluates to false?. > > When you're coming from another language like C or Perl where 0 is a false > condition, it can take a little while to get used to the Ruby way - but > after you get used to Ruby's rule for determining truth, it seems to make > sense. The rule is simple: the only things that evaluate to false are > false and nil, everything else is true. > > Phil >