$ irb

irb(main):001:0> true.class
=> TrueClass
irb(main):002:0> false.class
=> FalseClass
irb(main):003:0> 0.class
=> Fixnum

0 is not a boolean, so interpretation is up to the language.

Most common is 0 := false, 1 := true as you already know.
I think in Visual Basic it is 0 := false, -1 := true
Also possible 0 := false, not 0 := true

So it depends ... :-)



> --- Ursprgliche Nachricht ---
> Von: Xavier Noria <fxn / hashref.com>
> An: ruby-talk / ruby-lang.org (ruby-talk ML)
> Betreff: Re: Zero is true, but it isn't
> Datum: Thu, 20 Apr 2006 16:26:09 +0900
> 
> On Apr 20, 2006, at 1:51, John Johnson wrote:
> 
> > I was wondering today, so I tried this:
> >
> > puts "It's true" if 0
> >
> > Which prints "It's true", meaning 0 is not false. (This should  
> > surprise C/C++/etc. people).
> >
> > So that means
> > puts "It's equal" if 0 == true
> 
> You are seeing a particular case of the fact that the boolean  
> interpretation an object may be different from the object value  
> itself. And == is comparing object values, not boolean  
> interpretations. Then the result of == is interpreted in boolean  
> context, but by then 0 was seen as an integer already, which is  
> certainly different from the object true.
> 
> To make it apparent take "foo". The string "foo" is true in boolean  
> context, but it won't surprise you to realise that "foo" == true does  
> not hold.
> 
> -- fxn
> 
>