On Thu, Feb 09, 2006 at 01:45:22AM +0900, mental / rydia.net wrote: > Quoting Claudio Jeker <cjeker / diehard.n-r-g.com>: > > > IMO if it looks like a boolean expression it should act like a > > boolean expression. > > That's the point, isn't it? 0 isn't a boolean value. > Have you ever looked at boolean algebra. The use of 0 as false is just standard usage in boolean expressions. > You typically only see 0 -> false equivalences in languages that > don't have a distinct boolean type (C, Perl, etc...). Ruby's not > one of those. > ... and in bitwise boolean logic 0 meansi what? Even ruby has bitwise logic operators. If I use 0 in a boolean domain it should not return true. > > Why can't there be a to_bool converter for all numerical Classes? > > There is one; it's just called #nonzero? instead of #to_bool: > > if ( flags & 0x01 ).nonzero? > ... > end > But I have to explicitly use it. Ruby should use duck typing for boolean expression like it does it in many other cases. -- :wq Claudio