From: "Mark J. Reed" Date: 2003-07-15T06:52:58+09:00 Subject: Re: Booleans On Tue, Jul 15, 2003 at 06:17:46AM +0900, Austin Ziegler wrote: > On Tue, 15 Jul 2003 05:34:02 +0900, Mark J. Reed wrote: > >?I would also be happy if the test for falseness was less simplistic > >?than "false is false, nil is false, everything else is true". ?I am > >?constantly being bitten by the fact that 0 is true. > > If you *know* that you will be getting a Fixnum in response, > you can use Fixnum#nonzero? and Fixnum#zero? to get the tests that > you're after. Sure. Or just plain old != 0. But I always forget that I need to do anything at all beyond "if (expression returning Numeric)". After 20 years programming C and derivatives, I have simply internalized that zero is SUPPOSED to be false, dagnabit! But I do think it would be worthwhile to allow classes to specify their own truth values, even if Ruby as shipped doesn't take advantage of this feature. -Mark