From: Mathieu Bouchard Date: 2001-03-07T09:37:07+09:00 Subject: [ruby-talk:12197] Re: Another hook On Tue, 6 Mar 2001, Dave Thomas wrote: > If we're in to hooks, there's another that might be useful: > to_bool: > analogous to to_s, called whenever an object is used in a context > that requires a boolean value (this one came up on > #ruby-lang). Masochists could use this to emulate Perl Oh, btw, I also proposed that in [ruby-talk:5056]. > This could get rolled in to the new Boolean class (or whatever it will > be called). MetaRuby-current (cvs) has the following code in it: if not Object.const_defined?(:Boolean) then module Boolean; end class TrueClass; include Boolean; end class FalseClass; include Boolean; end end (so i don't have to compare objects to both true and false anymore...) > (So, let's see whose idea I've stolen this time :) lol matju