From: Christian Neukirchen Date: 2005-02-22T05:52:19+09:00 Subject: Re: destructive! operations Pit Capitain writes: > ES schrieb: >> Wouldn't it be possible to override the TrueClass, NilClass >> and FalseClass methods to yield the correct behaviour for >> this object? I'm assuming 'if something' expands to >> 'if something == true' or something like that? > > The objects false, true, and nil are encoded internally as 0, 2, and 4 > respectively. (You can get those values in Ruby with "p false.id".) > The only values for which RTEST returns false (in C) are the values 0 > and 4, in other words the objects false and nil. So more or less > > if something > > expands to > > if something != nil && something != false > > I think Christian is right that you cannot work around this in > Ruby. (Maybe Florian Gro� can do it...) If he could, we wouldn't beg for #to_bool whenever possible... > Regards, > Pit -- Christian Neukirchen http://chneukirchen.org