From: "David A. Black" Date: 2004-05-19T20:40:24+09:00 Subject: Re: Zero is true ... whoda thunk? Hi -- On Wed, 19 May 2004, Michael Geary wrote: > That's why Ruby's interpretation of zero as "true" seems extremely > peculiar to me. There's a geeky kind of logic to it, but it doesn't > map onto the real world at all. The real world is highly overrated as a template for programming languages and the concepts underlying them. Consider that the following expression evaluates to true in Ruby (and others): "The earth is flat." Of course one could explore and discuss this example in various ways, but the point is that there's no self-evident, semantically-based mapping between natural language and programming language here. The same is true of comparing the statements "I have zero of X" and "The expression 'I have non-zero of X' is false" and so forth. > p.s. Don't get me wrong, I *like* Ruby. :-) But, it has its warts > just like every programming language. Perhaps... but this isn't one of them. Really -- it may not be identical to C, Perl, etc. in this respect, but the implication that this is a design glitch is really off the mark and potentially misleading to people trying to understand how it works. To the other explanations or glosses on this design decision you can add: everything of a given class has the same Boolean value as everything else of that class. Fixnum objects (all of them) are true. There are no special cases, no legacy treatment, nothing thrown in "to make the people feel at home". It's utterly smooth and consistent in design, and it's designed carefully with full and deep awareness of how the same issue is handled in antecedent languages. David -- David A. Black dblack@wobblini.net