From: Ryan Tarpine Date: 2001-08-24T09:50:11+09:00 Subject: [ruby-talk:20226] Re: In Ruby 0 is true but nil is false.. or how to shoot yourself?.. Paul Prescod wrote: > jweirich@one.net wrote: >> >>... >> >> Everytime someone suggests making more things "false", I think of this >> conversation. > > How is it useful to know the complete set of things that are false in the > world? In an object oriented language, each object determines if it is > false. What is the complete list of objects in the Ruby universe that > respond false to the ".nonzero" message? I don't think you can innumerate > them. But does it matter? > In Ruby, it should be the to_b message, right? Obviously, we have to_i, to_f, and to_s. Not that this should be added, but if it were to be, it would make the most sense as to_b. When an object does not evaluate to the expected boolean, you shouldn't have to check nonzero, followed by size/length (checking if Enumerable was included), etc. Just one method, to keep it simple. Object#to_b would be true while NilClass#to_b would be false. if/unless/while/until could call to_b on the given expression. Just my $0.02 -- Ryan Tarpine, rtarpine@hotmail.com "Technology is a queer thing. It brings you great gifts in one hand, and it stabs you in the back with the other." -- C.P. Snow