From: Bill Atkins Date: 2004-10-30T03:05:46+09:00 Subject: Re: true? & false? I'm still skeptical about the usefulness of this, but I think the best implementation would be: def true.true? true end def false.false? false end I'm not actually sure, though, that these wouldn't belong in TrueClass and FalseClass. Bill On Sat, 30 Oct 2004 01:28:39 +0900, Mohammad Khan wrote: > On Fri, 2004-10-29 at 12:01, trans. (T. Onoma) wrote: > > On Friday 29 October 2004 11:55 am, Mohammad Khan wrote: > > | On Fri, 2004-10-29 at 11:48, Bill Atkins wrote: > > | > Well, all Objects must be nil or non-nil, but the idea of true/false > > | > doesn't apply to all objects. > > | > > | I agree with you on this point. > > | > > | I would ask, > > | If I would like to have true? and false? > > | what would be best class to put in? > > > > But it must be responded to by all classes. > > > > # true?&false?.rb > > # As suggested by Mohammad Khan > > > > class Object > > def true? ; false ; end > > def false? ; false ; end > > end > > > In my mind, I had this: > > class Object > def true? > return self == true ? true : false > end > > def false? > return self == false ? true : false > end > end > > irb(main):009:0> n = nil > => nil > irb(main):010:0> n.nil? > => true > irb(main):011:0> n.true? > => false > irb(main):012:0> n.false? > => false > irb(main):013:0> t = true > => true > irb(main):015:0> t.true? > => true > irb(main):016:0> t.false? > => false > irb(main):017:0> f = false > => false > irb(main):018:0> f.nil? > => false > irb(main):019:0> f.true? > => false > irb(main):020:0> f.false? > => true > > > > > class TrueClass > > def true? ; true ; end > > end > > > > class FalseClass > > def false? ; true ; end > > end > > > > Is this what you had in mind? > > > > T. > -- > Mohammad Khan > Legal Computer Solutions, Inc. > >