On May 19, 2004, at 8:43 AM, Mary M. Inuet wrote: > > "Michael Geary" <Mike / DeleteThis.Geary.com> wrote in message > news:10allar4vlk2092 / corp.supernews.com... >>> what makes zero >>> so special that it would warrant being false? >> >> Because in the real world, zero means false. >> >> Suppose you have zero quarts of milk in your refrigerator. I am >> visiting > and >> I ask: Got milk? >> > > I just wanted to note that I agree with you 100% and find any other > interpretation baffling. This is a common error for me - 99% of my > Ruby > programming errors stem from runtime NoMethodErrors on nil because of > Ruby's > failure to correctly interpret some boundary condition. If numbers > always > evaluate to true, it seems absurd to allow them to be used in > conditionals > predicating on truth - we should at least get a good diagnostic, IMHO. > Arguments about the elegance or uniformity of zero's truth are pretty > weak > in my opinion, due to the fact that Ruby does not exist in a vacuum. > LOTS > of external libraries, extensions, interfaces, etc, implicitly and > explicitly require zero to be false. Personally, I think that the > semantics > of the spaceship operator (<=> a <=> a -> -1, 0, +1 ) lend credence > to the > notion of correlation between the syntax and semantics of numeric > values > (especially zero). Honestly, I think that the comparison operator is a counter-example for zero being false. should ("a"<=>"a") == false? Breaking it down into english: compare the string "a" to the string "a" and determine if the comparison is false. In this case, the comparing two equal strings would yield false. I remember this from a C++ class. The teacher was explaining str_compare (i think that's the name) and she mentioned that a common error for students was to compare two strings and use the returned value as a boolean; since equal strings return false, that tended to confuse the student. She recommended never using the result of a comparison of that type as a boolean, since you might remember wrongly which was true. cheers, --Mark