>>>>> "Mark" == Mark Slagell <ms / iastate.edu> writes: Mark> By "inconsistency", do you mean with other languages? Mark> The rule on what-is-truth is simple in Ruby: nil and false Mark> are the only false things. Ruby is consistent on that rule, Mark> (which to those of us who are used to it) makes a whole lot Mark> of sense. I occasionally follow the Python newsgroup. Late last year the following conversation occured in that newsgroup. >>>>> "Carsten" == Carsten Geckelar <nospam / no.spam> writes: Carsten> `while true' would be more readable and clear than `while Carsten> 1'. By the way, explain a newbie that -1 is true. ;) >>>>> "Steve" == Steve Lamb <grey / despair.rpglink.com> writes: Steve> 0 is true, all else is false. And? :P >>>>> "Rainer" == Rainer Deyke <root / rainerdeyke.com> writes: Rainer> 0 is false, None is false, [] is false, () is false, {} is Rainer> false, and x is false where x is a class instance and Rainer> x.__nonzero__() returns false. Everything else is true. Rainer> I think. >>>>> "Alex" == Alex Martelli <aleaxit / yahoo.com> writes: Alex> Another couple of 'false's: a class instance which doesn't Alex> define __nonzero__ but does define __length__ when the Alex> latter returns 0; and, C-implemented user objects, similarly Alex> to class instances. Alex> I don't _think_ there are any more... >>>>> "David" == David Porter <jcm / bigskytel.com> writes: David> An empty string is also false. >>>>> "Tim" == Tim Hochberg <tim.hochberg / ieee.org> writes: Tim> also 0.0, 0L, 0+0j => anything the equals zero. Tim> This can be simplified somewhat by replacing [], (), {}, and Tim> "a class instance which doesn't define __nonzero__ but does Tim> define length when the later returns 0" with "a sequence of Tim> length zero". >>>>> "Carsten" == Carsten Geckelar <nospam / no.spam> writes: Carsten> Nice; It takes three tries of -- I assume -- experienced Carsten> Python programmers to find all cases of all statements Carsten> evaluating as false. ;) Carsten> Cheers, Carsten Everytime someone suggests making more things "false", I think of this conversation. -- -- Jim Weirich jweirich / one.net http://w3.one.net/~jweirich --------------------------------------------------------------------- "Beware of bugs in the above code; I have only proved it correct, not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)