From: Christian Szegedy Date: 2001-08-24T21:51:36+09:00 Subject: [ruby-talk:20282] Re: In Ruby 0 is true but nil is false.. or how to shoot yourself?.. --------------50EDEBA4A0616FB437570369 Content-Type: text/plain; charset=iso-8859-2 Content-Transfer-Encoding: 7bit Guillaume Cottenceau wrote: > > The inconsistency is because Ruby will silently assume than 0 is false. > > I would like that either "0" is false, or that testing for truth value for > a number would throw an exception. It would not help much. Actually, it is very useful that 0 is true (and any non-nil and non-false object). This gives the ultimate way to test whether you have an object or not. I think any change to it would make the language much worse. Christian -- signature file is under construction --------------50EDEBA4A0616FB437570369 Content-Type: text/html; charset=iso-8859-2 Content-Transfer-Encoding: 7bit Guillaume Cottenceau wrote:
 
The inconsistency is because Ruby will silently assume than 0 is false.

I would like that either "0" is false, or that testing for truth value for
a number would throw an exception.

It would not help much.

Actually, it is very useful that 0 is true (and any non-nil and non-false object).

This gives the ultimate way to test whether you have an object or not.

I think any change to it would make the language much worse.



Christian
-- 
signature file is under construction
  --------------50EDEBA4A0616FB437570369--