Hi -- On Tue, 2 Nov 2004, Mohammad Khan wrote: > On Sat, 2004-10-30 at 00:03, Yukihiro Matsumoto wrote: > > Hi, > > > > In message "Re: Another scrach on head" > > on Sat, 30 Oct 2004 03:38:43 +0900, Jamis Buck <jgb3 / email.byu.edu> writes: > > > > |No, I mispoke for the sake of simplification. nil and false _evaluate to > > |false_ in a boolean context, and everything else evaluates to _true_ in > > |a boolean context. > > > > Ruby never get passed on telephone test. > > > > "In Ruby, nil and false are false, but nil is not false, because false > > does not equal to nil.." > > > > matz. > > Hi Matz, > > Thanks for your reply. > What about 'true'? > > My point was, > > a = Whatever.new # other than NilClass or FalseClass > > if a > # block 1 > end > > if a == true > # block 2 > end > > block 1 and block 2 will be executed only when a.class is TrueClass. > > I guess, > in #1 > other than nil and false, everything is considering as true. > and in #2 > we are doing equality test with 'true' that will return a boolean. > > If, I am right, shouldn't we have two have method 'false?' and 'true?' that > will return boolean based on equality test > with false and true respectively just like nil?. I don't think the names are very clear. This would be weird, to me: a = "hi" puts "hello" if a.true? # no output I suppose it's symmetrical with .nil? and .zero? (i.e., "is this the actual object [nil or zero]?"), but in the case of true and false I find my mind defaulting to the Boolean state, rather than the object. #false? might be useful to avoid lengthier tests distinguishing among various permutations of falsehood. I can't see too many likely uses for #true? David -- David A. Black dblack / wobblini.net